See Also Properties Example
Description
A collection The Controls collection has a single property , Count , that specifies the number of elements in an array.
Usage
[form.]Controls(index)[.property][ = setting ]
form (index)[.property][ = setting ]
Remarks
The Controls collection enumerates loaded controls on a form and is useful for iterating through them. The index in the syntax is between 0 and Controls.Count-1. Note that Controls is a keyword but not a reserved word. It identifies an intrinsic form-level variable named Controls. If you omit the optional form reference, you must include the Controls keyword. If you include a form reference, you can omit the Controls keyword. For example, the following two lines have the same effect:
MyForm.Controls(6).Top = MyForm.Controls(5).Top + increment
MyForm(6).Top = MyForm(5).Top + increment
You can use Controls(index) as an argument to a function with a parameter of type Control.
Count
Help:
Forms Collection
Programmer's Guide:
Chapter 3, "Creating and Using Controls"
Chapter 8, "Objects and Instances"
The OBJECTS.MAK file referred to in Chapter 8 of the Programmer's Guide includes the following procedure to enable all currently loaded controls on a form (except menus).
Sub EnableControlsOn (Frm As Form, State As Integer)
Dim I ' Declare variable.
For I = 0 To Frm.Controls.Count - 1
If TypeOf Frm.Controls(I) Is Not Menu Then
Frm.Controls(I).Enabled = State
End If
Next I
End Sub