VBScript VarType function
VarType function returns a value indicating the subtype of a specified variable.
VarType function returns the following values:
- 0 = vbEmpty - represents an empty (uninitialized)
- 1 = vbNull - indicates Null (no valid data)
- 2 = vbInteger - An integer
- 3 = vbLong - represents a long integer
- 4 = vbSingle - represents a single-precision floating-point number
- 5 = vbDouble - represents a double-precision floating-point number
- 6 = vbCurrency - representing currency
- 7 = vbDate - Indicates the date
- 8 = vbString - represents a string
- 9 = vbObject - represents an automation objects
- 10 = vbError - indicates an error
- 11 = vbBoolean - represents a Boolean value
- 12 = vbVariant - showing Variant (only for array of variables)
- 13 = vbDataObject - represents a data access object
- 17 = vbByte - represents a byte
- 8192 = vbArray - represents an array
Note: If the variable is an array, the VarType () returns 8192 + VarType (array_element).Example: VarType array of integers () returns 8192 + 2 = 8194.
grammar
VarType(varname)
参数 | 描述 |
---|---|
varname | 必需。变量的名称。 |
Examples
Examples
<script type="text/vbscript">
x="Hello World!"
document.write(VarType(x) & "<br />")
x=4
document.write(VarType(x) & "<br />")
x=4.675
document.write(VarType(x) & "<br />")
x=Null
document.write(VarType(x) & "<br />")
x=Empty
document.write(VarType(x) & "<br />")
x=True
document.write(VarType(x))
</script>
x="Hello World!"
document.write(VarType(x) & "<br />")
x=4
document.write(VarType(x) & "<br />")
x=4.675
document.write(VarType(x) & "<br />")
x=Null
document.write(VarType(x) & "<br />")
x=Empty
document.write(VarType(x) & "<br />")
x=True
document.write(VarType(x))
</script>
Examples of the above output:
8
2
5
1
0
11
2
5
1
0
11
try it"
Complete VBScript Reference