View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Art Art is offline
external usenet poster
 
Posts: 587
Default Passing collections to an object

I did have a little trouble following it, but got what I needed to work. For
what it's worth, I pasted my test code below, in case it's of any use.
Actually I think my only problem was not using "Set" where I needed it.

Thanks again for letting me know it was doable.

'---This is a regular module---
Sub main()
Dim x As New Class1
Dim y As New Class2
Dim z
Set z = CreateObject("scripting.dictionary")
x.Name = "Art"
x.Age = 54
y.C1 = x
y.add = x
Set z = y.Coll
End Sub
'---End of module---


'---This is class 1---
Dim mName As String
Dim mAge As Integer

Property Let Name(ByVal Value As String)
mName = Value
End Property
Property Get Name() As String
Name = mName
End Property

Property Let Age(ByVal Value As Integer)
mAge = Value
End Property
Property Get Age() As Integer
Age = mAge
End Property
'---End of class 1---


'---This is class 2---
Dim mC1 As Class1
Dim z

Property Let C1(ByRef Value As Class1)
Set mC1 = Value
End Property
Property Get C1() As Class1
Set C1 = mC1
End Property

Property Let add(ByRef Value As Class1)
z.add 1, Value
End Property

Property Get Coll()
Set Coll = z
End Property

Private Sub Class_Initialize()
Set z = CreateObject("Scripting.Dictionary")
End Sub
'---End of Class 2---





"merjet" wrote:

P.S. If it's not clear from Tushar Mehta's post, yes, you can pass an
array to and from a Class. "Dim" a Class member variable as type
Variant and pass an array to it via a Property Let procedure.

Hth,
Merjet