Visual Basic Language Reference  

IsNumeric Function

Returns a Boolean value indicating whether an expression can be evaluated as a number.

Public Function IsNumeric(ByVal Expression As Object) As Boolean

Parameter

Expression
Required. Object expression.

Remarks

IsNumeric returns True if the entire Expression is recognized as a number; otherwise, it returns False.

IsNumeric returns True if the data type of Expression is Short, Integer, Long, Decimal, Single, or Short. It also returns True if Expression is a String that can be successfully converted to a Double. It returns False if Expression is of data type Date.

Example

This example uses the IsNumeric function to determine if the contents of a variable can be evaluated as a number.

Dim MyVar As Object
Dim MyCheck As Boolean
' ...
MyVar = "53"   ' Assign value.
MyCheck = IsNumeric(MyVar)   ' Returns True.
' ...
MyVar = "459.95"   ' Assign value.
MyCheck = IsNumeric(MyVar)   ' Returns True.
' ...
MyVar = "45 Help"   ' Assign value.
MyCheck = IsNumeric(MyVar)   ' Returns False.

See Also

IsArray Function | IsDate Function | IsDBNull Function | IsError Function | IsNothing Function | IsReference Function | Object Data Type | TypeName Function