WithEvents Definition

Syntax

[Dim | Private | Public] _
WithEvents name As objtype[, ...]

Group

Declaration

Description

Dimensioning a module level variable WithEvents allows the macro to implement event handling Subs. The variable's As type must be a type from a referenced type library (or language extension) which implements events.

See Also: Dim, Private, Public.

Example

Dim WithEvents X As Thing

Sub
Main
Set
X = New Thing
X.DoIt ' DoIt method raises DoingIt event
End
Sub

Private
Sub X_DoingIt
Debug
.Print "X.DoingIt event"
End
Sub