From RAD Studio API Documentation
Jump to: navigation, search


function VarAsType(const V: Variant; AVarType: TVarType): Variant;


extern DELPHI_PACKAGE System::Variant __fastcall VarAsType(const System::Variant &V, System::Word AVarType);


Type Visibility Source Unit Parent
function public
System.Variants System.Variants


Converts a variant to specified type.

VarAsType converts a variant to a specified type and returns a new Variant that has the specified type.

V is the Variant to convert.

VarType is a variant type code that indicates the type to which V should be converted. This can be one of the constants defined in the System unit, or it can be the type code for a custom variant type. It cannot include the varArray or varByRef bits.

VarAsType raises an exception if the variant cannot be converted to the given type. This will be EVariantError or one of its descendants, such as EVariantOverflowError or EVariantTypeCastError.

See Also