Collection of Collections? 
Author Message
 Collection of Collections?

Is it possible to create a collection whose members themselves consist of
collections? In other words, I'd like to create a kind of 'two dimensional'
collection, just like a two-dimensional array, only with the possibility of
using the collections ability to access entries via keys that need not be
integer numbers.

If such a thing is possible, I'd welcome any hints on how to do it (cause
I've been trying to find out not very successfully, myself...)

--
 ----
    -----------------------------------------------------------------------
[Insert joke here.]                                                       ----
                                                                             --



Tue, 30 Dec 2003 23:03:36 GMT  
 Collection of Collections?

Baus mumbled incoherently:

Quote:
> Is it possible to create a collection whose members themselves consist
> of collections?

Yes, paste the code below into a form with a single command button, it's
fairly self-expanatory.

Option Explicit

' "Top-level collection"
Private nCol As Collection

Private Sub Command1_Click()
    MsgBox nCol("nCol2").Item("Key2")
End Sub

Private Sub Form_Load()
    Dim nCol2 As Collection

    Set nCol = New Collection
    Set nCol2 = New Collection

    nCol2.Add "Item1", "Key1"
    nCol2.Add "Item2", "Key2"

    nCol.Add nCol2, "nCol2"
End Sub

-Stef



Tue, 30 Dec 2003 23:28:45 GMT  
 Collection of Collections?

Quote:


> Baus mumbled incoherently:
>> Is it possible to create a collection whose members themselves consist
>> of collections?
> Yes, paste the code below into a form with a single command button, it's
> fairly self-expanatory.

[snip]

Thank you, that helped. (Although I am not exactly sure what I made wrong
when I tried it but I guess that does not matter now...)

--
 ----
    -----------------------------------------------------------------------
[Insert joke here.]                                                       ----
                                                                             --



Fri, 02 Jan 2004 20:13:26 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. using collection of collections

2. collection in collection

3. Collections of Collections..how?

4. collections of collections

5. Collection of Collections

6. Collection of collections

7. Collection of Collections of Classes

8. VB4 class collections with collections

9. An ARRAY of a Collection of Collections !!??

10. Please!! help on COLLECTION of COLLECTIONS

11. collection into collection

12. User defined Collections within Collections

 

 
Powered by phpBB® Forum Software