How to Read Event Viewer in VB.NET

Written by jaime avelar
  • Share
  • Tweet
  • Share
  • Email

The Event Viewer is a program that's included with Microsoft operating systems. The Event Viewer lets administrators and users monitor events through event logs. Events are generated when an error is detected such as if a user authentication fails. Visual Basic.NET (VB.NET) is a computer object-oriented programming language developed by Microsoft. VB.NET is commonly used due to its flexibility and ease of use. In a few steps you can write VB.NET code to read the Event Viewer in your system.

Skill level:
Moderately Easy


  1. 1

    Start Microsoft Visual Basic Express and click "New Project..." on the left pane of your screen. Double-click "Windows Forms Application" to start your new project.

  2. 2

    Double-click "Button" on the "Tools" pane to create a new button. Double-click "ListBox" on the "Tools" pane to create a new list box control. Double-click "Button1" to open the "Form1.vb" module.

  3. 3

    Press "Ctrl+A" and press "Delete" to delete all code.

  4. 4

    Copy and paste the following code to your "Form1.vb" module.

    Public Class Form 1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim eventLogApp As New System.Diagnostics.EventLog("Application")
        Dim eventLogEntry As System.Diagnostics.EventLogEntry
        Dim eventCntr As Integer = 1
        For Each eventLogEntry In eventLogApp.Entries
            Me.ListBox1.Items.Add("Event Number:" & eventCntr)
            eventCntr = eventCntr + 1
    End Sub

    End Class

  5. 5

    Start your program by pressing "F5" and then clicking "Button1" to display event log entries through a list box.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.