objectvariableAs [New] Collection
The name of the Collection object
A Collection object allows you to store members of any data type, including object data types or even other collection objects, and to retrieve them using a unique key.
Collection objects allow us to create a form of associative array, which is an array whose members are indexed by something more meaningful than an integer. The real power of a collection comes by using collections with class objects. The Collection object is discussed in more detail in Chapter 3.
Collection objects are created in exactly the same way as other objects, as in:
objAs New Collection
Dim obj As Collection
obj= New Collection
In the former syntax, the Collection object is created at the time
obj variable is declared, which
may be sooner than you actually need the Collection object. The
latter syntax gives you more control over the creation process.
You can use a Collection object to store data of any data type, including object types and even other Collection objects.
The Add method of the Collection object is used to add items to the collection (see the Collection.Add entry).
Members of a collection can be accessed using either their ordinal number or their key, assuming that one was assigned at the time that the member was added to the collection (see the Collection.Item entry). ...