This function retrieves a value indicating the subtype of a variable.
VarType(varname)
The following table shows the return values of the VarType function.
Constant |
Value |
Description |
vbEmpty | 0 | Empty (uninitialized) |
vbNull | 1 | Null (no valid data) |
vbInteger | 2 | Integer |
vbLong | 3 | Long integer |
vbSingle | 4 | Single-precision floating-point number |
vbDouble | 5 | Double-precision floating-point number |
vbCurrency | 6 | Currency |
vbDate | 7 | Date |
vbString | 8 | String |
vbObject | 9 | Automation object |
vbError | 10 | Error |
vbBoolean | 11 | Boolean |
vbVariant | 12 | Variant (used only with arrays of Variants) |
vbDataObject | 13 | Data-access object |
vbByte | 17 | Byte |
vbArray | 8192 | Array |
The toolkit specifies these constants at run time. As a result, you can use the names anywhere in your code in place of the actual values.
The VarType function never returns the value for array by itself. It is always added to some other value to indicate an array of a particular type. The value for Variant is returned only when it has been added to the value for array to indicate that the parameter to the VarType is an array. For example, the value returned for an array of integers is calculated as 2 + 8,192, or 8,194. If an object has a default property, VarType (object) returns the type of its default property.