Export (0) Print
Expand All

How to: Raise an Event (Visual Basic) 

This example defines an event (TimeExpired) and uses the RaiseEvent statement to cause the event to occur.

Example

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 How to: Insert Snippets Into Your Code (Visual Basic).

Compiling the Code

This example requires:

  • Access to the members of the System namespace. Add an Imports statement if you are not fully qualifying member names in your code. For more information, see Imports Statement.

  • The Event statement to be at class level and not inside any procedure.

  • The RaiseEvent statement to be inside some procedure in your application.

See Also

Community Additions

ADD
Show:
© 2015 Microsoft