IsNumeric (function)




Returns True if expression can be converted to a number; returns False otherwise.


If passed a number or a variant containing a number, then IsNumeric always returns True.

If a String or String variant is passed, then IsNumeric will return True only if the string can be converted to a number. The following syntaxes are recognized as valid numbers:




If an Object variant is passed, then the default property of that object is retrieved and one of the above rules is applied.

IsNumeric returns False if expression is a Date.


Sub Main()
  Dim s$ As String
  s$ = InputBox("Enter a number.","Enter Number")

  If IsNumeric(s$) Then
    MsgBox "You did good!"
    MsgBox "You didn't do so good!"
  End If
End Sub

See Also

Variant (data type); IsEmpty (function); IsDate (function); IsError (function); IsObject (function); VarType (function); IsNull (function).

More information