![]() |
Deleting and writing over lines in VB6
For a program in class, I need to be able to search for a string in a text file (one word per line) and be able to either delete it or write over it, depending on what the user chooses. I can check for a match, but I don't know how to write over the line or delete it once i've found it. Any help is appreciated. i'll provide more info if needed.
Thanks, ---ae |
Here's a little pseudo code for ya for a function:
open text file then loop with a while not eof loop check string read in from text file against compairison string. if string == string then if userchoice == delete delete line and text so that there is no white space. elseif userchoice == overwirte Over write string with what ever the user wants. end if end if end while loop close text file end function. |
I hate the way sequential, and transaction file methods are drummed into students heads by teachers who learned to program in the 1970s.
The line-by-line concept was only adopted because that was how printers used to work. Nowadays files do not have to be organised by line breaks - just try parsing SGML in that way! Using a couple of well placed mids and replaces should do the trick, just search between vbcrlf's |
| All times are GMT -5. The time now is 12:54 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC