System.Variants.VarAsType

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

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

C++

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

Properties

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

Description

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