Sub App_Start
Form1.Show
' Specify the control and the Event
Ctrl = "TextBox1"
Event = "TextChanged"
' Names for the new Object and Event
CtrlObj = Ctrl & "_obj"
CtrlEvt = Ctrl & "_evt"
' Add a new object and associate it with the control
AddObject (CtrlObj, "Object")
Control(CtrlObj).New1(False)
Control(CtrlObj).FromControl(ctrl)
' Add a new Event object
AddObject (CtrlEvt, "Event")
' Make the new Event a TextChanged event of the specified control
' This makes the TextChanged event of the control call the NewEvent event handler of the Event Object
Control(CtrlEvt).New1(Control(CtrlObj).value, Event)
' Now make the NewEvent handler of the Event object call our event Sub.
AddEvent(CtrlEvt, NewEvent, "Some_NewEvent")
End Sub
Sub Some_NewEvent
Msgbox("Some_NewEvent!")
End Sub