CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2000
    Location
    England
    Posts
    11

    Passing VB structures over COM

    I need to send VB structures to a COM object that was developed with VC++ and have had no success.

    My use of VARIANTS with none structured datatypes has worked fine but structures are causing me problems. Would anyone be able to suggest a starting point?
    Thanks in advance
    Tony Goacher


  2. #2
    Join Date
    Apr 2000
    Posts
    737

    Re: Passing VB structures over COM

    I wonder why it doesn't work as VB variant should be type same as COM variant data type, which is VARIANTTAG (msdn).

    anyway, there is two other ways you can try,

    first, declare the structure in VC & VB, for instance

    in VB

    public type test
    test1 as long
    test2 as long
    end type

    in VC

    typedef struct
    {
    long test1;
    long test2;
    } test;

    there for the method, what you really need is to accept the address of the structure & case it, like this

    void testfunc(long structadr)
    {
    test* testvar;

    testvar = (test*)structadr;
    }

    and in vb

    dim testvar as test

    testfunc(varptr(testvar))

    and it should have pass the data to it.

    or, second way, still use VB variant data type and you need to pass the address of the actual data. refer http://vblib.virtualave.net, there is a function called VariantPtr in vbPointer of the activeX DLL that will help.

    HTH


  3. #3
    Join Date
    Apr 2000
    Posts
    737

    Re: Passing VB structures over COM

    sorry should pass

    testfunc(varptr(testvar.test1))




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