|
-
Oct 2nd, 2002, 03:32 PM
#1
Thread Starter
Addicted Member
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!
-
Oct 2nd, 2002, 03:35 PM
#2
-
Oct 2nd, 2002, 03:36 PM
#3
Fanatic Member
Do you mean
VB Code:
Public Property Get SomeValue(Byref strArray() As String)
End Property
Kinjal
Last edited by kinjalgp; Oct 2nd, 2002 at 03:42 PM.
-
Oct 2nd, 2002, 03:38 PM
#4
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
-
Oct 2nd, 2002, 03:44 PM
#5
Thread Starter
Addicted Member
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!
-
Oct 2nd, 2002, 03:52 PM
#6
Thread Starter
Addicted Member
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!
-
Oct 2nd, 2002, 04:04 PM
#7
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....
-
Oct 2nd, 2002, 04:23 PM
#8
Thread Starter
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|