VarType
The VarType function returns the subtype of an ASP variable.
We say subtype because all variables in ASP have the type of
Variant. The subtype determines what type of value is stored
in the variant. The chart below shows you all of the possible types
that a variable may hold:
| Type |
Value |
Comments |
| vbEmpty |
0 |
Uninitialized variable |
| vbNull |
1 |
No meaningfull data |
| vbInteger |
2 |
Whole number |
| vbLong |
3 |
Long integer |
| vbSingle |
4 |
Single-precision floating point number |
| vbDouble |
5 |
Double-precision floating point number |
| vbCurrency |
6 |
Decimal number to hold money values |
| vbDate |
7 |
Date value only (no time) |
| vbString |
8 |
Text string |
| vbObject |
9 |
Object refernences (use TypeName to determine object type) |
| vbError |
10 |
Holds an error object |
| vbBoolean |
11 |
Holds either True or False |
| vbVariant |
12 |
Only returned for array of variants |
| vbDataObject |
13 |
Data access component |
| vbDecimal |
14 |
Decimal number |
| vbByte |
15 |
Byte value (0 - 255) |
| vbArray |
16 |
Variable array |
If you call the VarType function and it returns the value
vbObject, you may use a subsequent call to TypeName
to determine which type of object the variable references. An
example of this is shown below:
Dim sEmpty Dim dDate Dim oHash dDate = Now() Set oHash = Server.CreateObject("Scripting.Dictionary")
Response.Write "VarType(sEmpty) = " & VarType(sEmpty) & "<BR>" Response.Write "VarType(dDate) = " & VarType(dDate) & "<BR>" Response.Write "VarType(oHash) = " & VarType(oHash) & "<BR>" Response.Write "TypeName(oHash) = " & TypeName(oHash) & "<BR>"
|
 |

|