Name
VarType Function
Syntax
function VarType(const V: Variant): Integer;
Description
VarType
returns a
Variant
’s type code. The type code
determines the actual data type of the Variant
value, and whether the Variant
is an array or a
reference.
See Chapter 6 for a list of variant type codes.
VarType
is a real function.
Tips and Tricks
The type code is a bit mask. The low-order 12 bits specify a type
code, and the higher bits specify additional type information. Use
the varTypeMask
constant to find the actual type
code. The possible modifiers are varArray
for an
array and varByRef
for indirect data.
Example
// Calling VarType is the same as accessing the VType field of the // TVarData record. The following two examples do the same thing. // (Accessing the field is slightly faster, but is harder to read.) I := VarType(V); I := TVarData(V).VType; if VarType(V) = varDateTime then TVarData(V).VDate := Now;
See Also
TVarData Type, Variant Type, VarIsArray Function, VarIsEmpty Function, VarIsNull Function |
Get Delphi in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.