Re: Problems regarding text filtering with Visual Basic
|
Libresio Gabriella |
|
12/7/2007 12:38:28 AM |
Hi,
Open the source file, and another text file, and copy line by line with mod function. Mid(TempString,20) gives you the message.
Regards Post Comments |
|
You really haven't made it clear which part of the process is giving you problems, which lines you want and don't want, or what version of VB you're using.
Gabriella, assuming that stripping off the date & time is what was required, I don't think a straight Mid() function like this will work properly because the length of the date varies. Possibly the time also, but we can't tell from this sample. You'd really need to do something like using Instr() to find the second space.
Post Comments |
|
Re: Thanks for your feedbacks...
|
Reknine Bellsoth |
|
12/7/2007 12:59:32 AM |
Hi Thanks for your feedbacks... so i am using Visual Basic 6.0... i am working on a software (SCADA) which writes automaticlly his system messages on his own log file... I only need to write a small program in VB 6.0 which reads all these system messages from this log file and write the selected lines (messages ) into another text file.... The filtering could be done with key words (like Socket:) If the keyword can be found in the line, this line should be copied in the other text file..
Regards
Post Comments |
|
That kind of filtering is rpetty simple, then. You just do a test like...
Code: ( vb ) If Instr(LineReadFromFile1, MyKeyWord) Then Print #2, LineReadFromFile1 End If
Post Comments |
|
Hi Here is my code.. But i can not copy the selected lines from test to test1 Have someone any idea?
Sub Main
Dim data As String FileCopy("C:\Documents and Settings\OTOMASYON\Belgelerim\Movicon Projects\GT EX TEST\LOGS\Network Services.log", "C:\test.txt")
Open "C:\test.txt" For Input As #1 Open "C:\test1.txt" For Append As #2
Do While Not EOF (1) Line Input #1, data If InStr(data, "Network") Then Print #2, data End If Loop
Close #1 Close #2
End Sub Post Comments |
|
Hi,
"InStr" Function Returns an Integer Value, if the String is Found, Change your If Condition :
Code: ( vb ) - Sub Main
- Dim data As String
- FileCopy("C:\Documents and Settings\OTOMASYON\Belgelerim\Movicon Projects\GT EX TEST\LOGS\Network Services.log", "C:\test.txt")
- Open "C:\test.txt" For Input As #1
- Open "C:\test1.txt" For Append As #2
- Do While Not EOF (1)
-
Line Input #1, data -
If InStr(data, "Network") >0 Then -
Print #2, data -
End If - Loop
- Close #1
- Close #2
- End Sub
Not very sure, why you are writing in Sub Main. You can write a General Procedure with some name Like (ImportLog) and Call the Proc wherever you want..
Regards Post Comments |
|