this may be a stupid question, but how would i delete a line from a file or (if asked to) modify the line?
Printable View
this may be a stupid question, but how would i delete a line from a file or (if asked to) modify the line?
Here is one way. If it's a sequential file, read the file line by line. If a line is not the line you want, immediately rewrite it to a new file. Do that until the line matches the line you want to act on. To delete the line simply do not write it to the new file, otherwise modify it and write it to the new file. At EOF, kill the old file and rename the new one to the old name.
You can Split(str,VbNewline)
Which will split the file into an array, the line # being the relative index into the array.