Coll1(1).Coll2(1).Property... ... Method or data member not found
You can't call the collection like this, as Coll2 is not a method or property of Coll1. Coll1(1). is going to return a collection item, Coll2, that can be accessed with it's methods/properties. You just need to keep track of what get referenced after each dot in your object call. The example below explains better than I can:
VB Code:
Private Sub ColCol()
Dim Col1 As Collection
Dim Col2 As Collection
Set Col1 = New Collection
Set Col2 = New Collection
Call Col1.Add(1, "One")
Call Col1.Add(2, "Two")
Call Col1.Add(3, "Three")
Call Col2.Add(Col1, "Col1")
MsgBox (Col2.Item("Col1").Item("One"))
Set Col2 = Nothing
Set Col1 = Nothing
End Sub
Last edited by Comintern; Oct 28th, 2005 at 10:45 AM.
Reason: clarify language.
I thought that the class_terminate would be called when the object is set to nothing. However, when I made my own,
Public sub destroy()
Set m_colPersons = Nothing
End Sub
and called it from a new button on the form: The msgbox that I put into your terminate event did not display until I closed the program!
So, is the idea that if this form1 was one of many forms in a project and it gets unloaded, setting the object to nothing in the terminate event makes sure that the memory is freed up? Is this because the class_terminate is responding to a message from the form?
Second question: Why are we not setting all of the Person objects in the collection to Nothing as we Terminate the collection?