Results 1 to 3 of 3

Thread: search

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    131

    search

    how can i search a .txt file for three stars ***
    if found delete them

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: search

    open the file into a string
    VB Code:
    1. mystr = Replace(mystr, "***", "")  'replace 3 stars together with nothing

    open file for output and print string to file
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: search

    VB Code:
    1. Dim tmp As String
    2.     Dim ff As Integer
    3.    
    4.     'read it...
    5.     ff = FreeFile
    6.     Open "c:\test.txt" For Input As #ff
    7.         tmp = Input(LOF(ff), ff)
    8.     Close #ff
    9.    
    10.     'replace *** with vbNullString...
    11.     tmp = Replace(tmp, "***", vbNullString)
    12.    
    13.     'write it back...
    14.     ff = FreeFile
    15.     Open "c:\test.txt" For Output As #ff
    16.         Print #ff, tmp;
    17.     Close #ff

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