Results 1 to 5 of 5

Thread: Deleting from a file!

  1. #1

    Thread Starter
    Hyperactive Member Tequila_worm's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    344

    Deleting from a file!

    Hey what's up, i was just wondering if i can lets say remove just one specific line from a txt file. so lets say its like this


    "Bla", "Ble", "Blue"
    "Pel", "Mel", "Melll"


    lets say i want to remove just the "Bla","Ble","Blue" from lets say a file calle Check.dat, is there a way i can do that, or no . Thx your your help again.

  2. #2
    Frenzied Member
    Join Date
    Aug 2001
    Posts
    1,075
    The way I've done something like this in the past is to open the file and then open a second, new file. Read every line from the original into the second, new file except for the line you want to delete. You then Kill the original file and rename (Name) the new file as the original.

    Greg
    Free VB Add-In - The Reference Librarian
    Click Here for screen shot and download link.

  3. #3
    DerFarm
    Guest
    Try this thread:

    http://www.vbforums.com/showthread.p...hreadid=135822

    I found it by doing a search with the key "remove one line"

  4. #4

    Thread Starter
    Hyperactive Member Tequila_worm's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    344

    Thank!

    Thank you. Wow alot harder then i thought.

  5. #5
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,526
    strText = "Delete lines containing this text"
    Open "TextFile.txt" For Input As #1
    Open "NewFile.txt" For Output As #2
    Do While Not EOF(1)
    Line Input #1, strTemp1
    If InStr(1,strTemp1,strText) = 0 Then Print #2, strTemp1
    Loop
    Close #1,#2
    Kill "TextFile.txt"
    Name "NewFile.txt" As "TextFile.txt"

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