Finding


Collection.Item (index)

References an item and returns a pointer to it
Returns a specific member of a Collection object either by position or by key.
Takes a parameter to specify a particular item in the collection can be a number or the name of the object.


Object
Required. An object expression that evaluates to an object in the Applies To list.


Index
Required. An expression that specifies the position of a member of the collection. If a numeric expression, index must be a number from 1 to the value of the collection's Count property. If a string expression, index must correspond to the key argument specified when the member referred to was added to the collection.


If the value provided as index doesn't match any existing member of the collection, an error occurs.
The Item method is the default method for a collection.
The following lines of code are equivalent:

objCollection(1) 
objCollection.Item(1)

Advanced

Consider the following
for
skey = "unique key of the collection"
set objObject = colMyCollection(skey)


when the key doesn't exist the above line does not reset the objObject to Nothing
therefore objObject keeps its previous value ??


The members of a collection can be iterated using a For Each Next loop


Important

Most of the collections in the Office model are 1-based which means they start at index position 1 rather than 0.


© 2019 Better Solutions Limited. All Rights Reserved. © 2019 Better Solutions Limited TopPrevNext