VARIANTVT function

Purpose

Determine the internal data type of the data stored in a Variant variable.

Syntax

numericvar = VARIANTVT(vrntvar)

Remarks

The VARIANTVT function returns the internal VT data type stored in the Variant.  The entire range of %VT_ prefixed values are documented by the OLE (COM) specification and are available in WIN32API.INC.

The most important values in this limited context include %VT_EMPTY (=0) and %VT_BSTR (=8), since most of the others are numeric formats automatically resolved by the LET statement and VARIANT# function.

Result

Equate

Content Type

0

%VT_EMPTY

0 or Empty string

1

%VT_NULL

Null string

2

%VT_I2

Integer

3

%VT_I4

Long-Integer

4

%VT_R4

Single

5

%VT_R8

Double

6

%VT_CY

Currency

7

%VT_DATE

Date

8

%VT_BSTR

Dynamic String

9

%VT_DISPATCH

Interface reference

10

%VT_ERROR

Error Code

11

%VT_BOOL

Boolean

12

%VT_VARIANT

Variant

13

%VT_UNKNOWN

 

16

%VT_I1

Byte

17

%VT_UI1

Byte

18

%VT_UI2

Word

19

%VT_UI4

DWORD

20

%VT_I8

Quad (signed)

21

%VT_UI8

Quad (unsigned)

22

%VT_INT

Integer

23

%VT_UNIT

Word

24

%VT_VOID

 

25

%VT_HRESULT

COM result code

26

%VT_PTR

Pointer

27

%VT_SAFEARRAY

VB Array

28

%VT_CARRAY

 

29

%VT_USERDEFINED

 

30

%VT_LPSTR

ANSI string

31

%VT_LPWSTR

Unicode string

64

%VT_FILETIME

 

65

%VT_BLOB

 

66

%VT_STREAM

 

67

%VT_STORAGE

 

68

%VT_STREAMED_OBJECT

 

69

%VT_STORED_OBJECT

 

70

%VT_BLOB_OBJECT

 

71

%VT_CF

 

72

%VT_CLSID

Class ID

&H1000

%VT_VECTOR

 

&H2000

%VT_ARRAY

Array

&H4000

%VT_BYREF

 

If a Variant contains a complete array, the Variant type is determined by adding the base type to the array modifier.  That is, for a string array, it would be %VT_BSTR plus %VT_ARRAY (= &H2008).

Quad arrays within Variants are not supported by most versions of Windows. The result from VARIANTVT can be used to see whether such an array was created properly.

See also

DIM, LET, OBJECT, SET, VARIANT#, VARIANT$