Count
Returns a Long containing the number of items in a Collection object. Read-only.
Syntax: object.Count
- object
- required An object expression that evaluates to a Collection object.
Example
This example uses the Collection object’s Count property to specify how many iterations are required to remove all the elements of the collection called MyClasses. Collection numeric indexes start at 1 by default. Because collections are reindexed automatically when a removal is made, the following code removes the first member on each iteration.
Dim Num As Long, MyClasses As Collection
Set MyClasses = New Collection
' ... assume MyClasses has been populated ...
For Num = 1 To MyClasses.Count ' Default collection numeric indexes
MyClasses.Remove 1 ' begin at 1.
Next