Event Definition

Syntax

[ | Public ] _
Event name[([param[, ...]])]

Group

Declaration

Description

User defined event. The event defines a sub that can be defined using WithEvents.. The values of the calling arglist are assigned to the params.

Access

If no access is specified then Public is assumed.

See also

RaiseEvent


 
Class Class1
    Event Changing(ByVal OldValue As String, ByRef NewValue As String)
 
    Private Value_ As String
 
    Property Get Value As String
        Value = Value_
    End Property
    
    Property Let Value(ByVal NewValue As String)
        RaiseEvent Changing(Value_, NewValue)
        Value_ = NewValue
    End Property
End Class
 
Dim WithEvents c1 As Class1
 
Sub Main
    Set c1 = New Class1
    c1.Value = "Hello"
    c1.Value = "Goodbye"
End Sub
 
Sub c1_Changing(ByVal OldValue As String, ByRef NewValue As String)
    Debug.Print "OldValue=""" & OldValue & """, NewValue=""" & NewValue & """"
End Sub