Article ID: 154448
Article Last Modified on 1/19/2007
Function CollectionCollection()
Dim element
Dim insideCollection As New Collection
Dim outsideCollection As New Collection
' Populate the first element of the collection and add
' it to the parent collection.
insideCollection.Add KEY:="fname", Item:="joe"
insideCollection.Add KEY:="lname", Item:="smith"
insideCollection.Add KEY:="age", Item:=12
outsideCollection.Add insideCollection
' Clear the collection - prevents duplication of elements.
Set insideCollection = Nothing
' Populate the second element of the collection and add
' it to the parent collection.
insideCollection.Add KEY:="fname", Item:="fred"
insideCollection.Add KEY:="lname", Item:="smith"
insideCollection.Add KEY:="age", Item:=14
outsideCollection.Add insideCollection
' Print the contents of the parent collection to the Debug window.
For Each element In outsideCollection
Debug.Print element("fname"), element("lname"), element("age")
Next
End Function
CollectionCollection
Keywords: kbhowto kbprogramming KB154448