G
Guest
Hi all,
I have three class modules that make up a simple object model, which
for ease of explanation I'll call:
# - clsMain
# - clsCollection
# - clsItem
clsCollection has a parent property that refers to clsMain.
clsItem has a parent property that refers to clsCollection
So far so good, but I'm having real trouble understanding how to
release the references to the parent objects correctly. I've heard
of "teardown" methods but can't find a good explanation or code-
snippet anywhere (and boy have I looked!). Currently my code tries to
release the references in the Class Terminate events as follows,
which I'm certain is incorrect.
-------------------------------------
(From clsItem)
Private mobjParent as clsCollection 'Module-Level Declaration
Sub Class_Terminate()
Set mobjParent = Nothing
End Sub
-------------------------------------
(From clsCollection)
Private mcolItems as collection 'Module-Level Declaration
Sub Class_Terminate()
Set mcolItems = nothing
End sub
-------------------------------------
Can anyone help or point me in the right direction? Apologies if I
haven't been clear enough, but you need to take into account I'm a
little confused myself!
Many thanks in advance,
Stuart
I have three class modules that make up a simple object model, which
for ease of explanation I'll call:
# - clsMain
# - clsCollection
# - clsItem
clsCollection has a parent property that refers to clsMain.
clsItem has a parent property that refers to clsCollection
So far so good, but I'm having real trouble understanding how to
release the references to the parent objects correctly. I've heard
of "teardown" methods but can't find a good explanation or code-
snippet anywhere (and boy have I looked!). Currently my code tries to
release the references in the Class Terminate events as follows,
which I'm certain is incorrect.
-------------------------------------
(From clsItem)
Private mobjParent as clsCollection 'Module-Level Declaration
Sub Class_Terminate()
Set mobjParent = Nothing
End Sub
-------------------------------------
(From clsCollection)
Private mcolItems as collection 'Module-Level Declaration
Sub Class_Terminate()
Set mcolItems = nothing
End sub
-------------------------------------
Can anyone help or point me in the right direction? Apologies if I
haven't been clear enough, but you need to take into account I'm a
little confused myself!
Many thanks in advance,
Stuart