Event Statement

Declares the signature for an event handler.

Syntax

Event event_name [ type_list ] [ parameter_list ] [ Where constraints ]

Parts

event_name
Mandatory name for the event
type_list
Optional. See Type List for more information.
parameter_list
Optional one or more variable declarations with a comma between each. See Parameter List for more information.
constraints
Optional. See Where Clause (Generics) for more information.

Instructions

event_name is a type that can be used in a parameter passed to a constructor or method. Such procedures must be passed the name of a procedure of type Sub that has a signature that agrees with that specified by parameter_list.

Examples

In a library module
Event WindowCloseEvent(#win As Window)
' ...
Dim closer as WindowCloseEvent
' ...
Method WhenClose(evt As WindowCloseEvent)
    closer = evt
End Method
In the program module
' Set the window's close event handler
#w.WhenClose Sub Quit

Sub Quit Handles WindowCloseEvent
    ' The "Handles" clause is the same as
    ' Sub Quit(#win As Window)
    #win.Close
End Sub

See also