CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: VARIANT

  1. #1
    Join Date
    Apr 1999
    Posts
    18

    VARIANT

    When I use some controls in VC,there have some function 's parameter type is VARIANT, how to invoke this type function?
    Please help me!


  2. #2
    Join Date
    May 1999
    Location
    Texas, USA
    Posts
    568

    Re: VARIANT

    A VARIANT is a structure that contains all of the OLE types. It doesn't actually contain them, it is a union of them. So a VARIANT type occupies 12 bytes. Check out the documentation on http://msdn.microsoft.com. Basically the structure consists of the following.

    struct VARIANT {
    VARTYPE vt;

    union {
    Byte bVal; // VT_UI1.
    Short iVal; // VT_I2.
    long lVal; // VT_I4.
    float fltVal; // VT_R4.
    double dblVal; // VT_R8.
    ... and so on

    You use it like the following.

    VARIANT var;

    // I am setting up the variant to hold a long value.
    var.vt = VT_I4;
    var.lVal = (long) 5;

    There are also helper classes to help with the VARIANT structure.
    MFC has a class, COleVariant, and there is a class, I use this one personally, defined in <comdef.h> called _variant_t. Check it out.

    Hope this helps,

    Wayne




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured