Creating a Control Array

See Also9AI60VY

A control array is made up of a group of controlsXX9KJT of the same type (for example, all list boxes) that share a common control name and a set of event procedures.  Each control in the array has a unique index number.  All items in a control array must have the same setting of the Name2016V9P property.

To create a control array

   1. Draw2JRMWVS the controls for the array.

   2. Select a control you want to include in the array.

   3. From the Properties window1K6JQPY, select the Name property.

   4. In the Settings box, type a name for the control.

   5. Choose the Enter button1MFBOJ1.

   6. Repeat steps 2-5 for each control you want in the array, typing the same name as in step 4.

     When you type the same Name for the second control, Visual Basic displays a dialog box asking you to confirm that you want to create a control array.

   7. Choose Yes to create the control array, or choose No to cancel the action.

 

Note   To remove a control from a control array, change the control's Name property.

When a control in the array recognizes an event, Visual Basic calls an event procedure for the group and passes the index as an additional argument, allowing you to determine which control recognizes the event.

Event procedures for control arrays are defined with the argument "(Index as Integer)."

 


See Also

Help:

Adding and Deleting Controls at Run Time10KLMP2

Creating a Menu Bar1DSHCUG

Creating a Menu Control Array131TFDP

Index Property3MKW18P (Control Arrays)

 

Programmer's Guide:

Chapter 3, "Creating and Using Controls"