RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
Variant::Type Method

Returns type code of a System::Variant instance.

Pascal
function Type: Integer;
C++
__fastcall int Type() const;

System::Variant::Type returns the type code of the given variant. The return value is constructed from the constants declared in the system.hpp header file. 

The lower twelve bits of a variant type code (the bits defined by the varSystem::Variant::TypeMask bit mask) define the type of the variant. The varArray bit is set if the variant is an array of the given type. The varByRef bit is set if the variant is a reference to a value of the given type as opposed to an actual value. 

The following table describes each of the variant type codes. 

System::Variant typeReturn valueContents of variant  

Variant type 
Return value 
Contents of variant 
0x0000  
The variant is Unassigned.  
0x0001  
The variant is Null.  
0x0002  
16-bit signed integer (type short int)  
0x0003  
32-bit signed integer (type int).  
0x0004  
Single-precision floating-point value (type float)  
0x0005  
Double-precision floating-point value (type double).  
0x0006  
Currency floating-point value (type Currency).  
0x0007  
Date and time value (type TDateTime).  
0x0008  
Reference to a dynamically allocated Unicode string.  
0x0009  
Reference to an OLE automation object (an IDispatch interface pointer).  
0x000A  
Operating system error code.  
0x000B  
16-bit boolean (type WordBool).  
0x000C  
Indicates another Variant.  
0x000D  
Reference to an unknown OLE object (an IUnknown interface pointer).  
0x0011  
Indicates an unsigned char.  
0x0100  
Reference to a dynamically allocated string (type AnsiString).  
0x0FFF  
Indicates the type of each array element.  
0x2000  
Indicates a Variant array.  
0x4000  
Indicates that the variant contains a reference as opposed to a value.  

The type of a System::Variant can be changed using the ChangeSystem::Variant::Type member function. 

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!