IsNumeric (function)

Syntax

IsNumeric(expression)

Description

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

Comments

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:

  &Hhexdigits[&|%|!|#|@]

  &[O]octaldigits[&|%|!|#|@]

  [-|+]digits[.[digits]][E[-|+]digits][!|%|&|#|@]

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.

Example

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

  If IsNumeric(s$) Then
    MsgBox "You did good!"
  Else
    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

I