How to check that user enters only digits
IsNumeric() function returns true for a string, which can me converted to number, like "1 2", "1e2". But if you need to check that string contains only digits? The simplest way I think is:
If strVar Like String(Len(strVar),"#") then
'Only numbers!
End If
Labels: VBA
2 Comments:
What about
Function IsDigitsOnly(strVar As String) As Boolean
IsDigitsOnly = (strVar Like "[0-9]")
End Function
Sorry, that's not correct.
Post a Comment
<< Home