Showing posts with label Button1. Show all posts
Showing posts with label Button1. Show all posts

Tuesday, 23 February 2016

How to Read Event Viewer in VB.NETIn Feburary 2016 23,

In Feburary 2016 23,
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.
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.
Press 'Ctrl+A' and press 'Delete' to delete all code.
Copy and paste the following code to your 'Form1.vb' module.Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickDim eventLogApp As New System.Diagnostics.EventLog('Application')Dim eventLogEntry As System.Diagnostics.EventLogEntryDim eventCntr As Integer = 1For Each eventLogEntry In eventLogApp.EntriesMe.ListBox1.Items.Add('Event Number:' & eventCntr)Me.ListBox1.Items.Add(eventLogEntry.EntryType.ToString)Me.ListBox1.Items.Add(eventLogEntry.TimeGenerated.ToString)Me.ListBox1.Items.Add(eventLogEntry.Source.ToString)Me.ListBox1.Items.Add(eventLogEntry.Category.ToString)Me.ListBox1.Items.Add(eventLogEntry.EventID.ToString)Me.ListBox1.Items.Add(eventLogEntry.MachineName.ToString)Me.ListBox1.Items.Add(eventLogEntry.Message.ToString)Me.ListBox1.Items.Add('-----------------------------------------------')eventCntr = eventCntr + 1Me.ListBox1.Refresh()NextEnd Sub
End Class
Start your program by pressing 'F5' and then clicking 'Button1' to display event log entries through a list box.
In Feburary 2016 23,