INFO: User-Defined Collections Are 1-Based Not 0-Based
Article ID: 129635
Article Last Modified on 12/9/2003
APPLIES TO
- Microsoft Visual Basic 4.0 Standard Edition
- Microsoft Visual Basic 4.0 Professional Edition
- Microsoft Visual Basic 4.0 Professional Edition
- Microsoft Visual Basic 4.0 16-bit Enterprise Edition
- Microsoft Visual Basic 4.0 32-Bit Enterprise Edition
This article was previously published under Q129635
SUMMARY
Predefined collections such as fields and forms are 0-based. User-defined
collections declared as New Collection are 1-based. It is not possible to
use an Option Base statement to set the default base to 0 or any other
number because a collection is not an array. This behavior is by design.
MORE INFORMATION
A collection is an object that contains a set of related objects called
members of the collection. A member object's position in the collection
can change whenever a change occurs in the collection. Therefore, the
position of any specific object in the collection may vary. It is
recommended not to use collection indices for iteration because they are
not guaranteed to be contiguous.
If you use the For Each construct to iterate through the members of the
collection, the base of the collection doesn't matter.
Keywords: kbinfo kbprogramming KB129635