This documentation is archived and is not being maintained.

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.

For more detailed information, see the Visual Basic topic IsNumeric Function (Visual Basic).

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.

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)

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

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

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0
Show: