VBScript TypeName 函數

TypeName 函數返回指定變數的子類型。
TypeName 函數返回下麵的值:
- Byte - 表示一個位元組值
- Integer - 表示一個整型值
- Long - 表示一個長整型值
- Single - 表示一個單精確度浮點值
- Double - 表示一個雙精度浮點值
- Currency - 表示一個貨幣值
- Decimal - 表示一個十進位值
- Date - 表示一個日期或時間值
- String - 表示一個字串值
- Boolean - 表示一個布爾值,True 或 False
- Empty - 表示一個未初始化變數
- Null - 表示無有效數據
- <object type> - 表示實際對象類型名
- Object - 表示一般對象
- Unknown - 表示未知對象類型
- Nothing - 表示還未引用對象實例的對象變數
- Error - 表示一個錯誤
語法
TypeName(varname)
參數 | 描述 |
---|---|
varname | 必需。變數的名稱。 |
實例
實例
<script type="text/vbscript">
x="Hello World!"
document.write(TypeName(x) & "<br />")
x=4
document.write(TypeName(x) & "<br />")
x=4.675
document.write(TypeName(x) & "<br />")
x=Null
document.write(TypeName(x) & "<br />")
x=Empty
document.write(TypeName(x) & "<br />")
x=True
document.write(TypeName(x))
</script>
x="Hello World!"
document.write(TypeName(x) & "<br />")
x=4
document.write(TypeName(x) & "<br />")
x=4.675
document.write(TypeName(x) & "<br />")
x=Null
document.write(TypeName(x) & "<br />")
x=Empty
document.write(TypeName(x) & "<br />")
x=True
document.write(TypeName(x))
</script>
以上實例輸出結果:
String
Integer
Double
Null
Empty
Boolean
Integer
Double
Null
Empty
Boolean
