Method

VarType


Description

Used to determine the data type of a variable.

Usage

result = VarType(value)

Part

Type

Description

result

Integer

Indicates the data type of value.

value

Variant

Value to be typed.

Notes

Result takes on the following values:

Result

Variant Class Constant

Description

0

TypeNil

Nil

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

Int64 or UInt64. This is the replacement for TypeLong.

4

TypeSingle

Single

5

TypeDouble

Double

6

TypeCurrency

Currency

8

TypeString

String

9

TypeObject

Object

11

TypeBoolean

Boolean

16

TypeColor

Color

18

TypeCString

CString

19

TypeWString

WString

20

TypePString

PString

21

TypeCFStringRef

CFStringRef

22

TypeWindowPtr

DesktopWindow.Handle

23

TypeOSType

OSType

26

TypePtr

Ptr

36

TypeStructure

Structure

38

TypeDateTime

DateTime

39

TypeDelegate

Integer

4096, logically OR'ed with the element type.

TypeArray

Array

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.