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 True如果数据类型为 BooleanExpression 、、ByteDecimalDoubleIntegerLongSByte、、ShortSingle、、 UIntegerULong,则UShort返回 。 它还返回 TrueExpression 一个 CharString或者 Object 可以成功转换为数字。 Expression 可以包含非数字字符。 IsNumeric如果TrueExpression字符串包含有效的十六进制数或八进制数,则返回。 IsNumeric如果包含以 + 或 - 字符开头或包含逗号的有效数值表达式,则还返回TrueExpression

IsNumeric如果数据类型为 Date,则FalseExpression返回 。 如果为数字CharString,或Object无法成功转换为数字,则返回FalseExpression该值。

适用于

另请参阅