You can add events in ActiveX Controls, Class modules and Forms.
You first have to declare the event:
Code:
Public Event MyCustomEvent()
Public Sub SomeMethod()
RaiseEvent MyCustomEvent
End Sub
If the above is declared in a class module or a form you have to use the WithEvents keyword to get the event procedure. If it's in an ActiveX Control this isn't necassary because all events are visible when you add the control to a form.
Let's say you used the above in a class module (named MyClass), and you want to use that class in a form. Then you could use code simular to this
Code:
'a form
Private WithEvents obj As MyClass
Private Sub Form_Load()
Set obj = New MyClass
obj.SomeMethod
End Sub
Private Sub obj_MyCustomEvent()
MsgBox "MyCustomEvent was fired!", vbInformation
End Sub
Best regards