VBScript TypeName 函数

定义和用法

TypeName 函数可指定变量的子类型。

TypeName 函数可返回的值:

描述
Byte字节值
Integer整型值
Long长整型值
Single单精度浮点值
Double双精度浮点值
Currency货币值
Decimal十进制值
Date日期或时间值
String字符串值
BooleanBoolean 值;True 或 False
Empty未初始化
Null无有效数据
<object type>实际对象类型名
Object一般对象
Unknown未知对象类型
Nothing还未引用对象实例的对象变量
Error错误

语法

TypeName(varname)
参数描述
varname必需的。变量的名称。

实例

dim x
x="Hello World!"
document.write(TypeName(x))
x=4
document.write(TypeName(x))
x=4.675
document.write(TypeName(x))
x=Null
document.write(TypeName(x))
x=Empty
document.write(TypeName(x))
x=True
document.write(TypeName(x))

输出:

String
Integer
Double
Null
Empty
Boolean