CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2000
    Posts
    12

    OCX property(let) with string array as parameter

    Hi all,

    I'm trying to create an OCX with a property
    which is of the type String(). It looks like
    this:

    public property let myProp(p() as string)
    public property get myProp() as string()



    When compiling everything seems fine. But
    when the program calls the property(let)
    the parameter p() is not initialized. So
    when calling the UBound(p)-function an
    error is raised. What is wrong about the
    property? Any ideas anyone?

    Thanks in advance,

    Alexander Kempf


  2. #2
    Join Date
    Apr 1999
    Location
    VA BEACH
    Posts
    467

    Re: OCX property(let) with string array as parameter

    The property should be declared as a variant.
    Arrays are handled differnely between programming languages, so COM passes all arrays as variants.

    Question is are you using this code from C++ eventually?



    Jim Hewitt
    Software Developer
    Liberty Tax Service
    www.LibertyTax.com

  3. #3
    Join Date
    Dec 2000
    Posts
    12

    Re: OCX property(let) with string array as parameter

    So you say I should declare the property as


    public property let myProp(p as Variant)
    public property get myProp() as Variant




    Is that what you meant? I already tried it
    with an variant array which also refused to work.

    To answer your question about using the OCX from
    C++: No, not yet.

    Thanks,

    Alexander Kempf


  4. #4
    Join Date
    Apr 1999
    Location
    VA BEACH
    Posts
    467

    Re: OCX property(let) with string array as parameter

    Yes, declare it as a variant.

    If you want to use the property from VB you can just pass the array and VB should convert it to a variant in the transfer.

    When doing it in C++ you will have a harder time because you have to pass it as a safearray, is the only reason I was asking about c++.

    thanks

    Jim Hewitt
    Software Developer
    Liberty Tax Service
    www.LibertyTax.com

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