Receiving Event Notifications

You can define an OnEntryWritten event handler for an instance of an EventLog component. If you add an EventLog component from the Component tab of the toolbox, you can double-click the EventLog component (shown in the component tray in Figure 20.7) to generate the event. An example of an OnEntryWritten event handler is shown next.

Figure 20.7. Nonvisual components like the EventLog component are managed in the component tray.

Private Sub EventLog1_EntryWritten(ByVal sender As System.Object, _
  ByVal e As System.Diagnostics.EntryWrittenEventArgs) _
  Handles EventLog1.EntryWritten

    MsgBox("Log Written")

End Sub

The ...

Get Visual Basic® .NET Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.