using collection of collections 
Author Message
 using collection of collections

I'd appreciate some recommendations on the best way to approach this
simple(?) VBA task. I'm new to vba, but familiar with perl, and miss
the easy use of associative arrays.

I want to create a structure like this:

<key1> = item1, item2, ...
<key2> = itema, itemb, ....

I don't know in advance how many keys I need or how many items will be
in each list. The example below doesn't work, but gives an idea of
what i'm thinking of. TopList is a collection of collections. If a new
key is found, then I want to add a new item (a new collection
object)to TopList, and then I want to add items to that sublist. This
is pretty easy to do in Perl, I'm sure there's an easy way to do it in
VB as well... Then I would like to list all the collections and their
contents of TopList

Sub test()

Dim TopList  As New Collection
Dim i, j As Integer

For i = 1 To 4
    For j = 1 To 3
        If TopList.Item(i) Is Nothing Then ' how do i test to see if
the collection exists?
            TopList.Add Item:=New Collection, Key:=i
        End If
        TopList.Item(i).Add j ' is this how i would add an entry to
the sublist?

End Sub

Sat, 10 Dec 2005 03:42:59 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Collections, Collections and More Collections

2. Document collections and AllForms collections

3. Creating a CDO collection from an Outlook collection

4. Storing a collection in a collection

5. collection in collection

6. Migrating to System.Collections.IEnumerator from VB6.Collection

7. Persisting a Collection of a Collection

8. Collection of Collections?

9. Collections, swapping items in a collection

10. Collections of

11. collections of collections

12. Collection of Collections


Powered by phpBB® Forum Software