|
-
Sep 14th, 2000, 11:36 AM
#1
Thread Starter
Addicted Member
Been searchin the MSDN Lib and have only ended up whating to kill myself.
I want to take this text file:
Code:
Event Log Alert (ELAlert) V2.1.1
Generate alerts from NT event logs to alphanumeric pager or external program.
Copyright (c) 1998,1999 Vincent A. Olivieri ([email protected])
Scanning event logs (ctrl-c to quit)...
***Alert time: Thu Sep 14 10:07:04 2000 Event time: Thu Sep 14 10:13:51 2000
SCIHOUDB06*App*ERR*Inventory Scanner*14*LDISCN32: The inventory server 10.10.1.152 did not respond.
Running: C:\nothing.log
C:\nothing.log - CreateProcess failed. system error 2
And parse these parts of the text file into a listbox or textbox:
Code:
***Alert time: Thu Sep 14 10:07:04 2000 Event time: Thu Sep 14 10:13:51 2000
SCIHOUDB06*App*ERR*Inventory Scanner*14*LDISCN32: The inventory server 10.10.1.152 did not respond.
this was just a short version as the real text file has many entires. Thanks so much.
-
Sep 14th, 2000, 12:26 PM
#2
Fanatic Member
Give this a whirl
Here ya go then. This picks up lines based on "***". It then stores that line in a list box, and flags that we want the next line as well. Then when we get the next line, we flag the boolean back to false.
Code:
Option Explicit
Private Sub Form_Load()
parseFile "c:\test2\test.txt"
End Sub
Private Sub parseFile(strFile As String)
Dim strLine As String
Dim blGetNextLine As Boolean
Open strFile For Input As #1
Do
'get a line from the file
Line Input #1, strLine
'if the first three chars = "***" then we want
'this line
If Left$(strLine, 3) = "***" Then
List1.AddItem strLine
'set a boolean to get the next line
blGetNextLine = True
ElseIf blGetNextLine = True Then
'if the boolean had been set, then we want
'this line as well, then set the boolean to false
List1.AddItem strLine
blGetNextLine = False
End If
Loop Until EOF(1)
Close #1
End Sub
Iain, thats with an i by the way!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|