CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2004
    Posts
    86

    Hi,what is the meaning and usage of COleVariant?

    I program between VC and ACCESS. Use CListView to show a *.mdb content.
    look thisto get room_name by room_id in a table)
    //============================================
    m_strTableName = _T("room");
    strSelect = _T("Select room_ID,room_name From [");
    strSelect += m_strTableName;
    strSelect += _T("]");
    m_pRecordset->Open(dbOpenDynaset,strSelect);
    while (!m_pRecordset->IsEOF()) {
    COleVariant var;
    var = m_pRecordset->GetFieldValue(0);
    StuffDlg.m_uaRoom.Add(var.lVal);
    var = m_pRecordset->GetFieldValue(1);
    StuffDlg.m_saRoom.Add(CCrack::strVARIANT(var));
    m_pRecordset->MoveNext();
    }
    //============================================
    !! StuffDlg.m_saRoom is a CStringArray.

    what is the meaning and usage of COleVariant.The explanation in MSDN is too abstract!!
    who can give me a simple example?

  2. #2
    Join Date
    Sep 1999
    Location
    Colorado, USA
    Posts
    1,002
    COleVariant is a class that wraps the VARIANT type (VARIANT structure) used in Visual Basic and VBA used by Microsoft Office apps like Excel, Access, Word. It makes it easier - less coding, more safety. When a C++ app "talks" to an Office app thru Automation, the data type that the Office app understands is VARIANT.

    Hope that is clearer.

    Steve

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