Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我想使用VB.NET列出事件日志中的最后20个条目_Vb.net - Fatal编程技术网

我想使用VB.NET列出事件日志中的最后20个条目

我想使用VB.NET列出事件日志中的最后20个条目,vb.net,Vb.net,我想列出应用程序日志中的最后20个条目。到目前为止,我所做的是: Dim eventLogApp As New System.Diagnostics.EventLog("Application") Dim eventLogEntry As System.Diagnostics.EventLogEntry Dim eventCntr As Integer = 1 For Each eventLogEntry In eventLogApp.Entrie

我想列出应用程序日志中的最后20个条目。到目前为止,我所做的是:

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

            If eventLogEntry.InstanceId = "1000" Then

                Me.ListBox5.Items.Add("Event Number:" & eventCntr)
                Me.ListBox5.Items.Add(eventLogEntry.Source.ToString)
                Me.ListBox5.Items.Add(eventLogEntry.Message.ToString)

                Me.ListBox5.Items.Add("-----------------------------------------------")
                eventCntr = eventCntr + 1
                If eventCntr = 20 Then Exit Sub

                Me.ListBox5.Refresh()
            End If
        Next

现在,它将列出,但从旧到新的日志,我并不真正需要。我只想列出新条目。

您可以在for循环之前调用
entries.Reverse()