Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Information.IsNumeric Method

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

Namespace:  Microsoft.VisualBasic
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

public static bool IsNumeric(
	Object Expression
)

Parameters

Expression
Type: System.Object

Required. Object expression.

Return Value

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

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. Expression can contain non-numeric characters. IsNumeric returns True if Expression is a string that contains a valid hexadecimal or octal number. IsNumeric also returns True if Expression contains a valid numeric expression that begins with a + or - character or contains commas.

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.

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)

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft