Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 23rd, 2005, 7:46 PM   #1
Aenimalius
Newbie
 
Aenimalius's Avatar
 
Join Date: Feb 2005
Posts: 3
Rep Power: 0 Aenimalius is on a distinguished road
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
__________________
Shameless Plug
Aenimalius is offline   Reply With Quote
Old Mar 24th, 2005, 8:52 AM   #2
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
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.
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old Mar 27th, 2005, 3:31 PM   #3
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
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
Rory is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:47 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC