VBScript VarType 函數(shù)
定義和用法
VarType 函數(shù)可返回指示指定變量的子類型的值。
VarType 函數(shù)可返回的值:
常數(shù) | 值 | 描述 |
---|---|---|
vbEmpty | 0 | 未初始化(默認(rèn)) |
vbNull | 1 | 不包含任何有效數(shù)據(jù) |
vbInteger | 2 | 整型子類型 |
vbLong | 3 | 長整型子類型 |
vbSingle | 4 | 單精度子類型 |
vbDouble | 5 | 雙精度子類型 |
vbCurrency | 6 | 貨幣子類型 |
vbDate | 7 | 日期或時(shí)間值 |
vbString | 8 | 字符串值 |
vbObject | 9 | 字符串子類型 |
vbError | 10 | 錯(cuò)誤子類型 |
vbBoolean | 11 | Boolean 子類型 |
vbVariant | 12 | Variant (僅用于變量數(shù)組) |
vbDataObject | 13 | 數(shù)據(jù)訪問對(duì)象 |
vbDecimal | 14 | 十進(jìn)制子類型 |
vbByte | 17 | 字節(jié)子類型 |
vbArray | 8192 | 數(shù)組 |
注釋:這些常數(shù)是由 VBScript 指定的。所以,這些名稱可在代碼中隨處使用,以代替實(shí)際值。
注釋:假如變量是數(shù)組,則 VarType() 會(huì)返回 8192 + VarType(數(shù)組元素)。舉例:整數(shù)數(shù)組的 VarType() 會(huì)返回 8192 + 2 = 8194 。
語法
VarType(varname)
參數(shù) | 描述 |
---|---|
varname | 必需的。變量的名稱。 |
實(shí)例
dim x x="Hello World!" document.write(VarType(x)) x=4 document.write(VarType(x)) x=4.675 document.write(VarType(x)) x=Null document.write(VarType(x)) x=Empty document.write(VarType(x)) x=True document.write(VarType(x))
分別輸出:
String Integer Double Null Empty Boolean
上一篇: VBScript UCase 函數(shù) 下一篇: VBScript LoadPicture 函數(shù)