From RAD Studio API Documentation
Jump to: navigation, search


function VarArrayCreate(const Bounds: array of Integer; AVarType: TVarType): Variant;


extern DELPHI_PACKAGE System::Variant __fastcall VarArrayCreate(const int *Bounds, const int Bounds_High, System::Word AVarType);


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


Creates a variant array.

VarArrayCreate creates a variant array with the bounds given by Bounds and the element type given by VarType.

The Bounds parameter must contain an even number of values, where each pair of values specifies the upper and lower bounds of one dimension of the array.

Note: The Bounds_size parameter is the index of the last value in the Bounds array. This is one less than the total number of values. Thus, Bounds_size must always be an odd number.

The element type of the array, given by the VarType parameter, is a variant type code. This must be one of the constants defined in the System unit. It cannot include the varArray or varByRef bits. The element type cannot be varString or a custom Variant type. To create a variant array of strings use the varOleStr type code. If the element type is varVariant, the elements of the array are themselves variants and can in turn contain variant arrays.

If VarArrayCreate is unable to create the array, an EVariantArrayCreateError is raised.

Note: Variant arrays with an element type of varByte are the preferred method of passing binary data between OLE Automation controllers and servers. Such arrays are subject to no translation of their data, and can be efficiently accessed using the VarArrayLock and VarArrayUnlock routines.

See Also

Code Examples