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
Printable View
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
If I understood you correctly, the List of those objects does not pass arrays as parameters, but collections.
Do you mean
VB Code:
Public Property Get SomeValue(Byref strArray() As String) End Property
Kinjal
you mean something like this:
VB Code:
Private mstrNames() As String Public Property Let List(NewName As String, Index As Long) If Index > UBound(mstrNames) Then ReDim Preserve mstrNames(Index) End If mstrNames(Index) = NewName End Property Public Property Get List(Index As Long) As String List = mstrNames(Index) End Property
You can then call it like so:
VB Code:
MyControl.List(1) = "Name One" MyControl.List(2) = "Name Two" MyControl.List(3) = "Name Three" MyControl.List(4) = "Name Four" MsgBox MyControl.List(3) 'This displays "Name Three" in a MsgBox
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.
:(
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.
Quote:
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:
'This will save them.... Dim lngCount as Long For lngCount = LBound(mstrNames) to UBound(strNames) 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....???? Next 'Then something similar.... to read them back 'Somehow figure out the Min/Max, read each item into the array...... 'I just can't think of a way off the top me head....
Thanx, it's already a good avenue.
:)