Results 1 to 8 of 8

Thread: Passing an array as property in OCX

  1. #1

    Thread Starter
    Addicted Member Aldragor's Avatar
    Join Date
    Oct 2002
    Location
    Québec, Canada
    Posts
    140

    Passing an array as property in OCX

    Does someone have already deal with passing a array of string (or something else) in property of an ActiveX component. I would like to have a property represanting an array of string like one in ListBox component -> .List property
    Mens sana in corpore sano
    ... pour mieux travailler!

  2. #2
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    If I understood you correctly, the List of those objects does not pass arrays as parameters, but collections.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  3. #3
    Fanatic Member kinjalgp's Avatar
    Join Date
    Apr 2000
    Location
    India
    Posts
    535
    Do you mean
    VB Code:
    1. Public Property Get SomeValue(Byref strArray() As String)
    2. End Property

    Kinjal
    Last edited by kinjalgp; Oct 2nd, 2002 at 03:42 PM.

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    you mean something like this:
    VB Code:
    1. Private mstrNames() As String
    2.  
    3. Public Property Let List(NewName As String, Index As Long)
    4.  
    5.   If Index > UBound(mstrNames) Then
    6.     ReDim Preserve mstrNames(Index)
    7.   End If
    8.  
    9.   mstrNames(Index) = NewName
    10.  
    11. End Property
    12.  
    13. Public Property Get List(Index As Long) As String
    14.  
    15.   List = mstrNames(Index)
    16.  
    17. End Property

    You can then call it like so:

    VB Code:
    1. MyControl.List(1) = "Name One"
    2. MyControl.List(2) = "Name Two"
    3. MyControl.List(3) = "Name Three"
    4. MyControl.List(4) = "Name Four"
    5.  
    6. MsgBox MyControl.List(3) 'This displays "Name Three" in a MsgBox
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5

    Thread Starter
    Addicted Member Aldragor's Avatar
    Join Date
    Oct 2002
    Location
    Québec, Canada
    Posts
    140
    Ok, if it's collection it doesn't change much because I try it also and wasn't able to get it work!

    I don't figure out how to use collection with ReadProperty and WriteProperty.
    Mens sana in corpore sano
    ... pour mieux travailler!

  6. #6

    Thread Starter
    Addicted Member Aldragor's Avatar
    Join Date
    Oct 2002
    Location
    Québec, Canada
    Posts
    140
    Yes techgnome it's looking something like that but I'm not sure if the data in the array will still there when swithing from and to desing time/run time.
    Mens sana in corpore sano
    ... pour mieux travailler!

  7. #7
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Originally posted by Aldragor
    Yes techgnome it's looking something like that but I'm not sure if the data in the array will still there when swithing from and to desing time/run time.

    Yeah, I didn't catch that..... what you may need to do is run through a loop, saving each item in the array......

    maybe like this:
    VB Code:
    1. 'This will save them....
    2. Dim lngCount as Long
    3.  
    4. For lngCount = LBound(mstrNames) to UBound(strNames)
    5.   ProprtyBag.WriteProperty "NameList_" & CStr(lngCount), mstrNames(lngCount), "" '--I'm not sure about the exact parameters, so bare w/ me...I think it's PropertyName, Value, Default Value....????
    6. Next
    7.  
    8. 'Then something similar.... to read them back
    9. 'Somehow figure out the Min/Max, read each item into the array......
    10. 'I just can't think of a way off the top me head....
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  8. #8

    Thread Starter
    Addicted Member Aldragor's Avatar
    Join Date
    Oct 2002
    Location
    Québec, Canada
    Posts
    140
    Thanx, it's already a good avenue.

    Mens sana in corpore sano
    ... pour mieux travailler!

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