qck.hlp (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
Creating a Control Array
                                                 Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
 Creating a Control Array
 
 ■ A control array is made up of a group of controls of the same type (for
   example, all option buttons) that share the same name and event
   procedures. While all items in a control array have the same CtlName
   property value, each control has a unique index number. This index number
   is used to identify a specific control in the array.
 
 ■ To create a control array:
 
   1. Add a control to the current form
      See: Drawing a Control
 
   2. Set the control's Index property value to 0
      See: Controls Summary
 
   3. Add controls with the same CtlName
      When you type the same CtlName for the second control, Visual Basic
      displays a dialog box asking you to confirm that you want to create a
      control array. Choose Yes to create the control array, or choose No to
      cancel the action. The Index property value will be automatically
      incremented as you add controls to the array.
 
 ■ Controls can be added to a control array at design time as outlined above
   or at run time using the LOAD statement. The example below uses the LOAD
   statement to add menu controls a run time:
 
         FOR i% = 1 TO 10
             LOAD MnuArray(i%)
             MnuArray(i%).Caption = STR$(i%)
         NEXT i%
 
   Note: The initial control MnuArray must be created at design time.
 
 ■ A primary use for control arrays is creating custom menus.
   See: Creating a Menu
 
 ■ To remove a control from a control array at design time, change the
   control's CtlName property. See: CtlName 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: Creating an Event Procedure
 
 ■ At run time, new controls in arrays can be loaded and unloaded like forms,
   except that no automatic loading occurs upon reference.
   See: Adding and Deleting Controls at Run Time
        LOAD Statement
        UNLOAD Statement