VARTYPE(variable)
Description
VARTYPE returns an integer that indicates the type of a variable. The required parameter, variable, is any variable that doesn't contain a user-defined type.
When variable is an array, the value returned is equal to the array constant plus the constant that specifies the element-type.
Table 25: VARTYPE return values
|
Constant |
Value |
Description |
|
vbEmpty |
0 |
Uninitialized (default) |
|
vbNull |
1 |
No valid data |
|
vbInteger |
2 |
Integer |
|
vbLong |
3 |
Long integer |
|
vbSingle |
4 |
Single-precision floating-point |
|
vbDouble |
5 |
Double-precision floating-point |
|
vbCurrency |
6 |
Currency |
|
vbDate |
7 |
Date |
|
vbString |
8 |
String |
|
vbObject |
9 |
Object |
|
vbError |
10 |
Error |
|
vbBoolean |
11 |
Boolean |
|
vbVariant |
12 |
Variant (only with arrays of Variants) |
|
vbDataObject |
13 |
Data-access object |
|
vbByte |
17 |
Byte |
|
vbArray |
8192 |
Array |
Example
REM VARTYPE Example
'VARTYPE returns variable type as an integer
DIM nInteger, nSingle
nInteger = CINT(44)
PRINT 44 & " is VARTYPE " & VARTYPE(nInteger)
nSingle = CSNG(99.44)
PRINT 99.44 & "isVARTYPE"&VARTYPE(nSingle)
Output
44 is VARTYPE 2
99.44 is VARTYPE 4
Related Items
ISARRAY, ISDATE, ISEMPTY, ISNULL, ISNUMERIC, ISOBJECT, TYPENAME