Overview (RunTime Controls Keywords)
AddArrayList
AddButton
AddCheckBox
AddComboBox
AddEvent
AddForm
AddImage
AddImageList
AddLabel
AddObject
AddPanel
AddRadioBtn
AddTextBox
AddTimer
Control
Sender
Overview (RunTime Controls Keywords) Top
There are four keywords which allow you to add controls and events when the programs runs.
AddControl keywords (changed in version 2.0) - Adds a control.
AddEvent keyword - Wires a control event to a specific sub.
Control keyword - Allows you to access controls using their names as a string.
Sender keyword - Access the control that raised the event. Very useful when many controls call the same sub.
AddArrayList Top
Adds an ArrayList to an application at runtime.
Syntax: AddArrayList (Name)
Example:
AddArrayList ("alFiles")
AddButton Top
Adds a Button to a Form or to a Panel at runtime.
Syntax: AddButton (Form | Panel, Name, Left, Top, Width, Height, Text)
Example:
AddButton (Form1, "Button1", 20, 30, 25, 80, "Click Me!")
AddCheckBox Top
Adds a CheckBox to a Form or to a Panel at runtime.
Syntax: AddCheckBox (Form | Panel, Name, Left, Top, Width, Height, Text)
Example:
AddCheckBox (Panel1, "chkMain", 120,230, 70, 30, "Main")
AddComboBox Top
Adds a ComboBox to a Form or to a Panel at runtime.
Syntax: AddComboBox (Form | Panel, Name, Left, Top, Width, Height)
Example:
AddComboBox (frmChoose, "cmbItems", 10, 10, 120, 30)
Note: ComboBox height is affected by its font size.
AddEvent Top
Wires a control event to a specific sub.
Useful when adding a control at runtime, or to wire many controls events to one sub.
You can use the Sender keyword to access the control that raised the event.
Syntax: AddEvent (Control Name, Event Name, Sub Name)
The following controls support AddEvent:
Button, CheckBox, ComboBox, Form, Image, MenuItems, Panel, RadioBtn, Table, TextBox and Timer.
Note: As in this example, Event Name is not quoted and can't be a variable.
Example:
AddButton (Form1, "Button1", 20,20,60,60,"Click Me")
AddEvent ("Button1", Click, "MySub")
AddEvent ("Form1",MouseDown", "DoSomething")
Sub MySub
Form1.Text = Sender.Text
End Sub
Sub DoSomething (x,y)
...
End Sub
AddForm Top
Adds a new Form to an application at runtime.
The form will not be visible until the statement FormName.Show
Syntax: AddForm (Form Name, Text)
Example:
AddForm ("frmAbout", "About")
frmAbout.Show
AddImage Top
Adds an image to a Form or to a Panel at runtime.
Syntax: AddIMage (Form | Panel, Name, Left, Top, Width, Height)
Example:
AddImage (Form1, "Image1", 80,80,100,100)
AddImageList Top
Adds an ImageList to an application at runtime.
Syntax: AddImageList (Name)
Example:
AddImageList ("ImageList1")
AddLabel Top
Adds a Label to a Form or to a Panel at runtime.
Syntax: AddLabel (Form | Panel, Name, Left, Top, Width, Height, Text)
Example: AddLabel (pnlOptions," Label1", 5, 5, 40, 20, "Option:")
AddObject Top
Adds an object from an external library at runtime.
The external library must first be referenced using Tools - Components...
Syntax: AddObject (Object Name, Object Type)
Example:
AddObject ("tab1", "TabControl")
AddPanel Top
Adds a Panel to a Form at runtime.
Syntax: AddPanel (Form, Name, Left, Top, Width, Height)
Example:
AddPanel (Form1, "Panel1", 200, 20, 100, 100)
AddRadioBtn Top
Adds a RadioBtn to a Form or a Panel at runtime.
Syntax: AddRadioBtn (Form | Panel, Name, Left, Top, Width, Height, Text)
Example:
AddRadioBtn (Form1, "RadioBtnRed", 30, 30, 60, 25, "Red")
AddTextBox Top
Adds a TextBox to a Form or to a Panel at runtime.
Syntax: AddTextBox (Form | Panel, Name, Left, Top, Width, Height, Text)
Example:
AddTextBox (Form1,"TextBox1", 20, 20, 50, 25, "")
Note: TextBox height is affected by its font size.
AddTimer Top
Adds a Timer to an application at runtime.
Syntax: AddTimer (Name)
Example:
AddTimer ("Timer1")
Timer1.Enabled = True
Control Top
Control keyword allows you to access a control using a string instead of its name.
Syntax: Control (Control Name)
Example:
Control ("Button1").Color = cGreen
Example:
For i = 1 To 10
Control ("Button" & i ).Color = cBlue
Next
Sender Top
Access the control that raised the event.
Sender keyword is useful when two or more controls events are wired to the same sub (using AddEvent).
Syntax: Sender
You can use Sender just like any other control name.
Example:
Sender.Text = "Hello"
If you omit the property after sender then it will return the controls name.
Example:
Msgbox (Sender) 'will display the controls name.