How to: Raise an Event (Visual Basic)
This example defines an event (TimeExpired) and uses the RaiseEvent statement to cause the event to occur.
Public Event TimeExpired(ByVal Status As String) Public Sub RaiseTimeExpiredEvent() RaiseEvent TimeExpired("Your time has run out") End Sub
This code example is also available as an IntelliSense code snippet. In the code snippet picker, it is located in Visual Basic Language. For more information, see.
Compiling the Code
This example requires:
Access to the members of thenamespace. Add an Imports statement if you are not fully qualifying member names in your code. For more information, see .
The Event statement to be at class level and not inside any procedure.
The RaiseEvent statement to be inside some procedure in your application.