Click to See Complete Forum and Search --> : How to search for a word in a text file?


elik
June 19th, 2001, 07:53 AM
Hello, I need to search a text file (which is actually a log file) for a word, ("command successful"), how do I do it? do You know? I thought to open the text file and do a loop...but how do I find the word there??
thanks a lot!


Eli

Kdev
June 19th, 2001, 08:09 AM
dim nFile as integer, sLine as string

nFile = FreeFile

open "C:\MyDirectory\MyFile.log"
while not eof(nFile)
line input #nFile, sLine
if inStr(sLine, "command successful") > 0 then
msgbox "Word Found!"
goto Finish
end if
wend
msgbox "Word Not Found!"
Finish:


-K