|
-
June 24th, 2001, 11:01 AM
#1
How to search a text file??
Hello, I need to search a text file for two different words. ones I've found the first word, I have to find the next word IN THE NEXT 6 LINES ONLY. the code that i have wrote, find two words in a document but not in a 6 line range. do you know how to write such a code?
Thanks.
the code is:
Public Function Search_Results(Txt_File_PathName, File_to_check, Cmnd_to_chck) As Boolean
Dim nFile As Integer, sLine As String
nFile = FreeFile
Open Txt_File_PathName For Input As #1 ' to read from
While Not EOF(nFile)
Line Input #nFile, sLine
If InStr(sLine, File_to_check) > 0 Then '"put " & File_to_check) > 0 Then
'MsgBox "Word Found!"
GoTo Continue_Cmnd_to_chck
End If
Wend
'MsgBox "Word Not Found!"
Search_Results = False
Continue_Cmnd_to_chck:
While Not EOF(nFile)
Line Input #nFile, sLine
If InStr(sLine, Cmnd_to_chck) > 0 Then
'MsgBox "Second Word Found!"
Search_Results = True
End If
Wend
Close #1
End Function
Eli
-
June 24th, 2001, 11:33 AM
#2
Re: How to search a text file??
Continue_Cmnd_to_chck:
dim LineCount as Integer
While Not EOF(nFile)
LineCount = LineCount + 1
Line input #nFile, sLine
If InStr(sLine, Cmnd_to_chck) > 0 then
'MsgBox "Second Word Found!"
Search_Results = true
End If
If LineCount > 6 then Exit Function
Wend
Tom Cannaerts
[email protected]
Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
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
|