Share this page

# Example: lrc_CreateVBCollection

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;

Tips to improve your search results... VuGen Function Reference Version 25.1-25.3 Function Reference 25.1-25.3 All View Local Help Center View Online Help Center Version: