Method
VarType
Description
Used to determine the data type of a variable.
Usage
result = VarType(value)
Part |
Type |
Description |
---|---|---|
result |
Indicates the data type of value. |
|
value |
Value to be typed. |
Notes
Result takes on the following values:
Result |
Variant Class Constant |
Description |
---|---|---|
0 |
TypeNil |
|
2 |
TypeInt32 |
Integer types of 32 bits or less, signed or unsigned. This is equivalent to TypeInteger. To detect 64-bit integers, use TypeInt64. |
3 |
TypeInt64 |
|
4 |
TypeSingle |
|
5 |
TypeDouble |
|
6 |
TypeCurrency |
|
8 |
TypeString |
|
9 |
TypeObject |
|
11 |
TypeBoolean |
|
16 |
TypeColor |
|
18 |
TypeCString |
|
19 |
TypeWString |
|
20 |
TypePString |
|
21 |
TypeCFStringRef |
|
22 |
TypeWindowPtr |
|
23 |
TypeOSType |
|
26 |
TypePtr |
|
36 |
TypeStructure |
|
38 |
TypeDateTime |
|
39 |
TypeDelegate |
|
4096, logically OR'ed with the element type. |
TypeArray |
In the case of an array, the result is 4096 logically OR'ed with the array element type. You can get the element type by calling Variant.ArrayElementType. See the example for getting the VarType of an Integer array.
Sample code
The following line of code returns 8 (data type of String):
Var dataType As Integer = VarType("Herman")
The following returns 4098 (data type of an array (4096) logically OR'ed with the VarType of the element type of Int32 (2)).
Var a(2) As Int32 = Array(0, 1, 2)
Var dataType As Integer = VarType(a) ' 4098
Compatibility
All project types on all supported operating systems.