Visual Basic Reference
Count Property (ActiveX Controls)
See Also Example Applies To
Returns the number of objects in a collection.
Syntax
object.Count
The object placeholder is an object expression that evaluates to an object in the Applies To list.
Remarks
You can use this property with a For...Next statement to carry out an operation on the forms or controls in a collection. For example, the following code moves all controls on a form 0.5 inches to the right (ScaleMode property setting is 1 or vbTwips):
For I = 0 To Form1.Controls.Count - 1
Form1.Controls(I).Left = Form1.Controls(I).Left + 720
Next I
You can also use this kind of structure to quickly enable or disable all controls on a form.
When used with the If TypeOf statement, you can cycle through all controls and change, for example, the Enabled property setting of only the text boxes or the BackColor property setting of only the option buttons.