CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2000
    Location
    Israel,tel-aviv
    Posts
    25

    How to search for a word in a text file?

    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

  2. #2
    Join Date
    Jan 2001
    Posts
    165

    Re: How to search for a word in a text file?


    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



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured