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
嘗試一下»
完整的VBScript參考手冊