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 (with Variants) statement and VARIANT# function.

Result

Equate

Content Type

0

%VT_EMPTY

An Empty Variant

1

%VT_NULL

Null value

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

IDispatch

10

%VT_ERROR

Error Code

11

%VT_BOOL

Boolean

12

%VT_VARIANT

Variant

13

%VT_UNKNOWN

IUnknown

14

%VT_DECIMAL

Decimal

16

%VT_I1

Byte (signed)

17

%VT_UI1

Byte (unsigned)

18

%VT_UI2

Word

19

%VT_UI4

DWORD

20

%VT_I8

Quad (signed)

21

%VT_UI8

Quad (unsigned)

22

%VT_INT

Long-Integer

23

%VT_UINT

DWord

24

%VT_VOID

A C-style void type

25

%VT_HRESULT

COM result code

26

%VT_PTR

Pointer

27

%VT_SAFEARRAY

VB Array

28

%VT_CARRAY

A C-style array

29

%VT_USERDEFINED

User Defined Type

30

%VT_LPSTR

ANSI string 

31

%VT_LPWSTR

Unicode string

36

%VT_RECORD

UDT

64

%VT_FILETIME

A FILETIME value

65

%VT_BLOB

An arbitrary block of memory

66

%VT_STREAM

A stream of bytes

67

%VT_STORAGE

Name of the storage

68

%VT_STREAMED_OBJECT

A stream that contains an object

69

%VT_STORED_OBJECT

A storage object

70

%VT_BLOB_OBJECT

A block of memory that represents an object

71

%VT_CF

Clipboard format

72

%VT_CLSID

Class ID

&H1000

%VT_VECTOR

An array with a leading count

&H2000

%VT_ARRAY

Array

&H4000

%VT_BYREF

A reference value

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, Just what is COM?, OBJECT, LET (with Variants), VARIANT#, VARIANT$, VARIANT$$, What is an object, anyway?