ObjectEvent Event, EventParameter Object Examples

The first example below uses the ObjectEvent event to print all parameter names and values.

Option Explicit
Private WithEvents extObj As VBControlExtender

' Code to set the object variable to a user control not shown.

Private Sub extObj_ObjectEvent(Info As EventInfo)
   Dim p As EventParameter
   Debug.Print Info.Name

   For Each p In Info.EventParameters
      Debug.Print p.Name, p.Value
   Next
End Sub

The second example allows you to check for a generic event raised by the control.

Private Sub extObj_ObjectEvent(Info As EventInfo)
   Dim p As EventParameter
   Select Case Info.Name
   Case "UserName"
      ' Check User name value.
      MsgBox Info.EventParameters("UserName").Value
   ' Other cases now shown
   Case Else ' Unknown Event
      ' Handle unknown events here.
   End Select
End Sub