Previous Top Next

The control keyword is now deprecated.
The new syntax for referring a control or object with a string is:
ControlType (Name As String)

For example to change the color of ten buttons named button1, button2, ..., button10 you should write:
For i = 1 to 10
            Button("Button" & i).Color = cBlue

The old syntax:

Control keyword allows you to access a control using a string instead of its name.
The Control keyword can be used with objects as well.
Syntax: Control (Control Name [,Type])

The following properties does not require you to specify the type:
Text, Left, Top, Width, Height, Visible, Enabled, Focus, BringToFront, Color, FontColor, FontSize, Refresh, Dispose, Name, Image, Checked, IgnoreKey, SelectionLength, SelectionStart, ScrollToCaret, Multiline and LoadPicture.

Type can be any type from the following list or any object type from one of the referenced libraries:
ArrayList, Button, CheckBox, ComboBox, Calendar, Form, Image, ImageButton, ImageList, Label, ListBox, Menu, NumUpDown, OpenDialog, Panel, RadioBtn, SaveDialog, TextBox, Table and Timer.

Control ("Button1").Color = cGreen

For i = 1 To 10
            Control ("Button" & i ).Color = cBlue