Events

Standard code modules have no way of handling events.
Code to handle events must be put inside a class module.
Look in the object browser to see all events for a particular class


Event Declaration


Public Event MyEvent(ByVal Text As String) 
Public Event BeforeClose(ByRef Cancel As Boolean)


RaiseEvent Function

Any class that creates an instance of a class can be notified when something happens

RaiseEvent MyEvent("hello") 


Example

Create a class module called MyClass and add the following code:


Public Event MyEvent(ByVal Text As String) 

Create another class module called MyCallingClass and add the following code:

Private WithEvents MyObject As MyClass 

Private MyObject_MyEvent(ByVal Text As String)

End Sub


© 2019 Better Solutions Limited. All Rights Reserved. © 2019 Better Solutions Limited TopPrevNext