access the variant

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jainchar
    New Member
    • Jan 2009
    • 14

    access the variant

    hello
    I am creating a VARIANT that stores a integer value of variable but variable is not initialize.In my code the variable are "r" and"c" where r and c are the value of row and column of a table.I am using it in a split function of Cell class of my project.The code for which i create for VARIANT is as follows and syntax of Split function are as follows.Please help me how i use this variant in my code.

    The code for variant is

    VARIANT v;
    VariantInit(&v) ;
    v.vt=VT_14;
    V_I4(&v)=r;
    VARIANT v1;
    VariantInit(&v1 );
    v1.vt=VT_14;
    V_I4(&v1)=r;


    The syntax for Split function is

    void Split(VARIANT *NumRows,VARIAN T * NumColumns)

    Then what shouild i do, please help me.
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Can you describe this function declaration

    void Split(VARIANT *NumRows,VARIAN T * NumColumns)

    in English?

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      This code looks fishy:
      Code:
       
      VARIANT v;
      VariantInit(&v);
      v.vt=VT_14;
      V_I4(&v)=r;
      I see the VARIANT v being defined. I see the VARIANT being initialized. I see the discriminator being set to VT_14, which is not correct as there is no VT_14 for a VARIANT. That should be VT_I4. But in any case I do not see the LONG being placed in the VARIANT.

      Where do you set v.lval?

      This code V_I4(&v)=r also looks odd. Maybe you set v.lval inside the V_I4 function but assigning r to the return of V_I4 accomplishes nothing. In any case, V_I4 is a poor name for a function since it is so close to the VARIANT discriminator enum values.

      Comment

      • jainchar
        New Member
        • Jan 2009
        • 14

        #4
        thanx for ur suggestion

        I am using it and there is no problem but in the following code there was syntax problem.please tell me where is the error

        VARIANT v;
        VariantInit(&v) ;
        v.vt=VT_I4;
        v.intVal=r;

        VARIANT v1;
        VariantInit(&v1 );
        v1.vt=VT_I4;
        v1.intVal=c;
        if(cell.Split(( v*),(v1*)))
        {
        .
        .
        .
        }

        it gives the error in if block of syntax error:')'.U have to suggest me to used lVal which is used for LONG but i m using integer and i m using intVal.so what should i do.

        Comment

        • weaknessforcats
          Recognized Expert Expert
          • Mar 2007
          • 9214

          #5
          First read the documentation on VARIANT before trying to use it. VT_I4 is for a LONG and you do use lVal.

          An INT is VT_INT and there you use intVal.

          A little Google is all you need:
          VARIANT and VARIANTARG

          Comment

          Working...