elik
June 24th, 2001, 11:01 AM
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
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