Sub Expression
Returns the address of the given event handler, or defines a lambda expression.
Syntax
Operator construct
Sub procedure_name
Expression construct
Sub ( [ parameter_list ] ) expression
Block construct
Sub [ ( [ parameter_list ] ) ]
[ statements ]
End [ Sub ]
Parts
procedure_name- The name of an event handler.
parameter_list- Mandatory in the expression construct.
- Optional in the block construct.
- Zero or more declarators with a comma between each, all between parentheses.
expression- Mandatory expression. The type of the expression is the return type of the procedure.
statements- Optional one or more statements.
End- Completes the expression.
You can also use
End Sub. You can make one of these mandatory with the directive@Option End. See @Option Directive for more information.
Instructions
Operator construct
The procedure procedure_name must have the clause Handles.
You use an element of the event type to store the address returned by Sub.
The element can be a variable or procedure parameter, or a value returned by a function or property.
Lambda constructs
TODO
Examples
Operator construct
Event MouseEvent(x As Int32, y As Int32, btn As MouseButtons)
win.OnClick = Sub ClickHandler
Sub ClickHandler Handles MouseEvent
' ...
End Sub