Compartilhar via


IsNumeric Function (Visual Basic) 

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

Public Function IsNumeric(ByVal Expression As Object) As Boolean

Parameters

  • Expression
    Required. Object expression.

Remarks

IsNumeric returns True if the data type of Expression is Boolean, Byte, Decimal, Double, Integer, Long, SByte, Short, Single, UInteger, ULong, or UShort. It also returns True if Expression is a Char, String, or Object that can be successfully converted to a number.

IsNumeric returns False if Expression is of data type Date. It returns False if Expression is a Char, String, or Object that cannot be successfully converted to a number.

Example

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

Dim testVar As Object
Dim numericCheck As Boolean
testVar = "53"
' The following call to IsNumeric returns True.
numericCheck = IsNumeric(testVar)
testVar = "459.95"
' The following call to IsNumeric returns True.
numericCheck = IsNumeric(testVar)
testVar = "45 Help"
' The following call to IsNumeric returns False.
numericCheck = IsNumeric(testVar)

Requirements

Namespace: Microsoft.VisualBasic

Module: Information

Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)

See Also

Reference

IsArray Function (Visual Basic)
IsDate Function (Visual Basic)
IsDBNull Function
IsError Function
IsNothing Function
IsReference Function
Object Data Type
TypeName Function (Visual Basic)