AddEvent
Previous Top Next

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