deletring a line of text from a text file

  • Thread starter Thread starter Leo
  • Start date Start date
L

Leo

Hello all,

I need to read a text file and delete the first line of text found then save
it and close it (from either vb or vba)

I cannot seem to find info on deleting lines from a text file anywhere. If
anyone has any code or links or suggestions I'd appreciate it very much

thank you
 
Hello all,
I need to read a text file and delete the first line of text found then save
it and close it (from either vb or vba)

I cannot seem to find info on deleting lines from a text file anywhere. If
anyone has any code or links or suggestions I'd appreciate it very much

What you have to do is to

Open the original file for input
Open a new file for output.
Read a line from the original file.
Check to see if this is a line you want to delete. If it is, then skip the
next step.
Write the line to the new output file.
Go back to see if there are more lines in the original file to be read. If
not, do the following steps
Close both files, KILL the original file (or rename it - much safer)
Rename the new file to the original file's old name.

Done.

Tom Lake
 
Back
Top