Keyword

RaiseEvent


Description

Used on a class to call the implementation of an event definition on a subclass.

Usage

RaiseEvent EventName [ (parameters) ]

Part

Type

Description

EventName

The name of the event that you want to trigger.

Parameters

Parameters to EventName, if any.

Notes

EventName is the name of the event that you want to call. If the event requires parameters, then they are passed as the optional parameter to RaiseEvent. RaiseEvent is useful when you have an Event Definition that has the same name as a method and the ordinary way to call an event definition is ambiguous.

The only place you can use RaiseEvent is in the class definition where you added the Event Definition. In particular, you cannot raise an event from an instance of the class on the window, nor can you raise the event from outside the class. If you want to arbitrarily call an event, you will need to create a supporting method within the class as well that raises the event.

If the actual event is not implemented on the subclass, then nothing gets called.

Important

Even in the case where the event is not implemented by the subclass, if the event signature includes a return type, the empty value of that return type will be returned. For example, if the event returns a Boolean, False will be returned. You can avoid this by using IsEventImplemented to determine first if the event has been implemented or not. IsEventImplemented is currently not supported for iOS and Android.

Sample code

' MyEvent is an Event Definition on the class
RaiseEvent MyEvent

' MyTestEvent is an Event Definition with String and Integer parameters
RaiseEvent MyTestEvent("Hello", 42)

' For an event that returns a value you can call it like this
Var value As Integer
value = RaiseEvent MyReturnEvent("Hello")

' RaiseEvent is optional, so you can also call the event by using its name
MyEvent
MyTestEvent("Hello", 42)
value = MyReturnEvent("Hello")

Compatibility

All project types on all supported operating systems.