Hi all.
I am trying to create a collection of class modules. (Originally, I wanted to have a collection of user defined types. But after hours of head banging realized VBA doesn't let you do that)
I think that the problem I am having has to do with the fact that the class i want to add to the collection has two class module's in it. [ See Below ]
' This is the class module that I want to add to a collection,
' Lets call it cMaster:
Private pA As cAlpha
Private pB As cBeta
' Gets and lets here...
Public Property Get A() As cAlpha
Public Property Let A( a_ As cAlpha )
Public Property Get B() As cBeta
Public Property Let B( b_ As cBeta )
Note: cAlpha and cBeta are each Class Modules that I created.
One question, do I need to call New on cAlpha and cBeta members?
Sub Init()
Set pA = New cAlpha
Set pB = New cBeta
End Sub
Because right now I do:
Dim myMaster As cMaster
Set myMaster = New cMaster
Call myMaster.Init
Now, I would LIKE to do the following:
Dim Arhs As cAlpha
Set Arhs = New cAlpha
Arhs.val = something
Dim Brhs As cBeta
Set Brhs = New cBeta
Brhs.val = something
myMaster.A = Arhs
myMaster.B = Brhs
' Create a collection to store all the masters
Dim AllMasters As Collection
Set AllMasters = New Collection
' BUT, ERROR EXECUTING LINE BELOW:
AllMasters.Add myMaster
The error is as follows:
Run-time error '91':
Object variable or With block variable not set
BUT WHERE?
Thanks to anyone that can help!
Bookmarks