Events are declared using event declarations. An event declaration consists of either an identifier and a delegate type or a method declaration. The method declaration, if specified, must be a subroutine (that is, no return type) and must not have a body or an End
construct. Attributes specified on the method declaration apply to the event itself. If a delegate type is specified, the delegate type may not have a return type. The accessibility domain of the parameter types must be the same as or a superset of the accessibility domain of the event itself.
In addition to the member name added to the type's declaration space, an event declaration implicitly declares several other members. Given an event named E
, the following members are added to the declaration space:
EEventHandler
is introduced whose declaration matches the method declaration and which has the same accessibility as the event.EEvent
.add_E
, which takes the delegate type and has the same accessibility as the event.remove_E
, which takes the delegate type and has the same accessibility as the event.raise_E
, which takes the delegate type and has the same accessibility as the event.If a type attempts to declare a name that matches one of the above names, an error will result. It is not possible to override or overload any of the introduced members, although it is possible to shadow them in derived types. Events may be shared.
Event
EventOrDelegate [ EventImplementsClause ] LineTerminator(
[ FormalParameterList ] )
] |As
DelegateTypeNameShared