Export (0) Print
Expand All
1 out of 1 rated this helpful - Rate this topic

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
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).

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 (.NET Namespace and Type).

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

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

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.