Collection Count Property

Syntax objectvariable.Count objectvariable Use: Required

Data Type: Collection object

Object variable referring to a Collection object.


Returns the number of members in the collection. Rules at a Glance

Collections are 1-based; that is, the index of the first element of a collection is 1. In contrast, arrays are 0-based; by default, the index of the first element of an array is 0.


For i = 1 To colMyCollection.Count

Set colSubCollection = colMyCollection.Item(CStr(i)) MsgBox colSubCollection.Item("Name")

168 Chapter 7- The Language Reference

Set colSubCollection = Nothing Next i

Programming Tips & Gotchas

Because collections are 1-based, you can iterate the members of a collection by using index values ranging from 1 to the value of objectvariable.Count.

See Also

Collection Object, Collection.Add Method, Collection.Count Property, Collection.Item Method

Was this article helpful?

0 0

Post a comment