Information.IsNumeric(Object) 方法

定義

回傳 Boolean 一個值,表示式是否能以數字來評估。

public:
 static bool IsNumeric(System::Object ^ Expression);
public static bool IsNumeric(object Expression);
static member IsNumeric : obj -> bool
Public Function IsNumeric (Expression As Object) As Boolean

參數

Expression
Object

必須的。 Object 表達式。

傳回

回傳 Boolean 一個值,表示式是否能以數字來評估。

範例

以下範例使用該 IsNumeric 函數來判斷變數內容是否能被評估為數字。

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)

備註

IsNumeric若資料型態ExpressionBooleanByteSByteDecimalDoubleSingleULongIntegerLongShortUIntegerUShort,則回傳 。TrueExpression是 、 CharObjectString,且可成功轉換為數字,則該系統也會回傳TrueExpression 可以包含非數字字元。 IsNumericExpression 是包含有效十六進位或八進位數的字串,則回傳TrueIsNumericExpression包含以 + 或 - 字元開頭的有效數字表達式,或包含逗號,則 也回傳True

IsNumeric若資料型別Date為 ,則Expression回傳 False 。 若Expression為 、 CharStringObject無法成功轉換為數字,則會回傳False

適用於

另請參閱