Imports System.Diagnostics
Partial Class VBEventLogReport
    Inherits System.Web.UI.Page

    Protected Sub btnTestReport_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnTestReport.Click
        Dim logs As EventLog() = EventLog.GetEventLogs()
        Dim applog As EventLog = Nothing

        Dim log As EventLog
        For Each log In logs
            If log.LogDisplayName.ToLower() = "application" Then
                applog = log
                Exit For
            End If
        Next log

        If Not (applog Is Nothing) Then
            Dim entry As EventLogEntry
            For Each entry In applog.Entries
                If entry.Source.ToLower() = Me.txtEventSource.Text Then
                    Dim row As New TableRow()
                    Dim cell As New TableCell()
                    cell.Text = entry.InstanceId.ToString()
                    Dim cell1 As New TableCell()
                    cell1.Text = entry.Source
                    Dim cell2 As New TableCell()
                    cell2.Text = entry.Message

                    row.Cells.Add(cell)
                    row.Cells.Add(cell1)
                    row.Cells.Add(cell2)

                    tblReport.Rows.Add(row)
                End If
            Next entry
        End If
    End Sub
End Class
