Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Passing collections to an object
Hi,
I'm having some difficulties with some classes I set up. I'd like to have each instance of my class "own" a dictionary object. I can set it up in the class and work with it. My problem is in communicating it outside of the class, or alternatively passing a dictionary object to my class either through a method or a procedure. I'm getting the feeling that you just can't do this. Is that true? Is there something I'm missing? Along with this I'd like to be able to pass an array to or from an object. Can this be done? I'd appreciate any advice, or even some fairly definitive bad news. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Passing collections to an object
|
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Passing collections to an object
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Passing collections to an object
I'm surprised -- I had thought I couldn't do it. I'll read through the post
tomorrow (actually later today) when I'm awake (it's 1:00 AM here). I think this will save me a lot of effort. "merjet" wrote: See Tushar Mehta's post he http://groups.google.com/group/micro...b70a9ca1a2533f Hth, Merjet |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Passing a variant object to a C++ dll | Excel Programming | |||
Passing a .NET DataSet object to Excel to be used with VBA | Excel Programming | |||
Passing a Label object to another procedure | Excel Programming | |||
passing an object | Excel Programming |