Results 1 to 2 of 2

Thread: searching a text file.

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    Launceston, Tasmania, Australia
    Posts
    44

    Post

    how do you search a text file for a certain word and then delete it from that text file in vb 5?

    ------------------
    Mooose

  2. #2
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105

    Post

    Read a text file record into a string.
    Loop through the string looking for the word in question.
    When you find it, modify/replace the existing string.


    In the following example, I remove any occurence of a single quote " ' ".

    Code:
    Open sImportFile For Input As #3
    
    Do Until sLine = ENDOFTABLE 
       ncheck = 1
       stest = "'"
       sLine = sCust
       Do Until ncheck = 0
           ncheck = InStr(1, sLine, stest, vbTextCompare)
           If ncheck > 0 Then
               sLine1 = Mid(sLine, 1, ncheck - 1)
               sLine2 = Mid(sLine, ncheck + 1, Len(sLine))
               sLine = sLine1 & " " & sLine2
           End If
       Loop
       Line Input #3, sLine
    Loop

    [This message has been edited by JHausmann (edited 02-09-2000).]

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