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, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft