how to check if string only contains numbers

D

Dirk Goldgar

John said:
IsNummeric()

That won't necessarily give the desired result, since IsNumeric will,
for example, return True for "-$23E01" . If you really want only the
digits 0-9 in the string, you can test it with a function like this:

'----- start of code -----
Function IsAllDigits(CheckString As String) As Boolean

If CheckString Like "*[!0-9]*" Then
IsAllDigits = False
Else
IsAllDigits = True
End If

End Function

'----- end of code -----
 
Top