lrc_CreateVBCollection

VB Collection Support

Creates a Visual Basic Collection object.

HRESULT lrc_CreateVBCollection( SAFEARRAY *items, _Collection** pCollection ); 
*items A pointer to a variant array containing the items.
**pCollection A pointer to a pointer(double reference) where the collection will be placed.

The lrc_CreateVBCollection function creates a Visual Basic (VB) Collection object filled with the safe array values, and returns a collection interface pointer into pCollection. A VB collection is a SafeArray of variants implemented as an interface by COM.

The first time the collection is encountered, VuGen creates the interface using lrc_CreateVBCollection. Subsequently, the code refers to this collection.

Return Values

lrc Return Values

Parameterization

You cannot use standard parameterization for any arguments in this function.

Example

This example shows how VuGen prepares the data for a VB collection and creates it.

//Build the Variant

{
    VariantArray items;
    VARIANT var0 = lrc_variant_short("65");
    VARIANT var1 = lrc_variant_BSTR("first");                        // this value is the name tag of 65
    VARIANT var2 = lrc_variant_short("90");
    VARIANT var3 = lrc_variant_BSTR("second");                            // this value is the name tag of 90
    items = Create2DVariantArray(0, 2, 0, 2);
    PutElementIn2DVariantArray(items, 0, 0, var0);
    PutElementIn2DVariantArray(items, 0, 1, var1);
    PutElementIn2DVariantArray(items, 1, 0, var2);
    PutElementIn2DVariantArray(items, 1, 1, var3);
   lrc_CreateVBCollection(items, (__Collection**)&__Collection_0, CHECK_HRES);
}
Example:  Output:
The output will be a collection containing two named values:
1. 65 named first
2. 90 named second
If names were not entered, the collection would only contain two values, 65 and 90.
Referencing a Collection
The next section shows how the code would subsequently refer to this collection:
__Collection * coldata =(__Collection*)__Collection_0;
lrc__SanityCheckA_ProcessCollection(_SanityCheckA_0, &coldata, CHECK_HRES);
__Collection_0 =(__Collection*)coldata;