Using Collection Index Numbers

Most object accessor methods allow you to specify an individual object in a collection either by name or by number. Using the object's index number is usually faster. If you use the object's name, Visual Basic must resolve the name to the index value; if you use the index value, you avoid this extra step.

There are, however, some significant advantages to specifying an object in a collection by name. One advantage is that using an object's name makes your code easier to read and debug. In addition, specifying an object by name is safer than specifying it by index number, because the index value for an object can change while your code is running. For example, a menu's index number represents the menu's position on the menu bar; therefore, the index number can change if menus are added to or deleted from the menu bar. This is one instance where faster isn't necessarily better. You should use this technique only when you're sure that the index value cannot change.