Freetutes.com

VB6 beginners tutorial - Learn VB6

Advanced VB6 tutorial - Learn Advanced VB6

Systems Analysis - System analysis and Design tutorial for Software Engineering


You are here: Visual Basic > Advanced VB6 tutorial > Chapter 4

Using Specific Items Within the Forms Collection in Visual Basic 6

Each object in the collection can also be referred to by its specific ordinal number. This is an item number automatically assigned as the new items are added to the collection.

When referring to the ordinal number of a form, you must always remember that the Forms Collection is 0-based. The first item in the collection will always have the ordinal value of 0. The following lines demonstrate using the item value:

Forms(0).Caption
Forms(1).Name
Forms(2).Width

This code assumes that a VB project has three forms and that all forms have been loaded into memory. The first line will return the Caption of the very first item (item 0) in the collection. The second line will return the Name property of Form(1). The third line will return the value of the last form's width.

These code examples show how easy referencing specific items in the collection can be. This can be an alternative method to using the specific form names in a given project. With the Forms Collection,
you also do not have to know the name of a given form to control it. This will assist in manipulating forms generated at runtime.

Using the forms collection topics

See Also


  

<< Previous | Contents | Next >>

Home | About Us | Privacy Policy | Contact Us

Copyright © Freetutes.com | All Rights Reserved