944,179 Members | Top Members by Rank

Ad:
You are currently viewing page 1 of this multi-page discussion thread
Sep 11th, 2006
1

How to delete a row in text file?

Expand Post »
Hello to everyone, i have a project which base on text file. and i already know how to view the text file using a listbox, what i want to know is on how to delete a specific row in text file.. thanks
Similar Threads
Reputation Points: 13
Solved Threads: 1
Junior Poster in Training
royaloba is offline Offline
54 posts
since Sep 2006
Sep 11th, 2006
0

Re: How to delete a row in text file?

post an example of the textfile, and we can go from there. The concept is fairly simple, however. You open the text file, and while you are reading in all the contents, compare each line with whatever you are looking for (say, the persons social security number), and then if they do not match, add that line to a string (or to another, temp file), and if they DO match, simply don't add it to the new file (or the string variable).
Last edited by Comatose; Sep 11th, 2006 at 10:26 am.
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Sep 11th, 2006
0

Re: How to delete a row in text file?

2005/11/11 17:36:13, Event:Access, Door:entry, Card No.:1234, Description:333
2005/11/11 17:36:17, Event:Access, Door:entry, Card No.:1234, Description:333
2005/11/11 17:36:20, Event:Access, Door:entry, Card No.:2222, Description:222
2005/11/11 17:36:26, Event:Access, Door:entry, Card No.:2222, Description:222

hello sir this is the sample of the text file... would you please give me a code which can i delete a specific row... thanks Comatose
Reputation Points: 13
Solved Threads: 1
Junior Poster in Training
royaloba is offline Offline
54 posts
since Sep 2006
Sep 11th, 2006
0

Re: How to delete a row in text file?

How are you going to decide which row? The user has a listbox, and the listbox has all this same information? Will they be deleting the row date, time, cardno or description?
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Sep 11th, 2006
0

Re: How to delete a row in text file?

thanks for your response.. my project is to create a time and attendance using a reader which the reader createss a textlog
like this

2005/11/11 13:32:45, EventIN Error, Door:entry, Description:201:44000
2005/11/11 13:39:58, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 13:39:59, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 13:40:03, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 13:40:26, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 13:40:28, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 13:48:58, Event:Card No. Error, Door:entry, Description:66:19157
2005/11/11 13:48:58, EventIN Error, Door:entry, Description:66:19157
2005/11/11 14:24:03, EventIN Error, Door:entry
2005/11/11 15:19:59, Event:Card No. Error, Door:entry, Description:66:19157
2005/11/11 15:20:03, EventIN Error, Door:entry, Description:66:19157
2005/11/11 15:20:05, EventIN Error, Door:entry, Description:66:19157
2005/11/11 15:20:50, Eventoor Group Error, Door:entry, Card No.:2229, Description:66:19157
2005/11/11 17:36:05, Eventoor Group Error, Door:entry, Card No.:2229, Description:66:19157
2005/11/11 17:36:13, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:36:17, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:36:20, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:36:26, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:36:41, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:36:45, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:36:51, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:37:19, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:37:36, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:37:45, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:37:54, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:38:11, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:38:20, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:39:40, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:41:04, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:43:51, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:50:58, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:51:11, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:51:44, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:52:31, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:52:47, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:52:55, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:53:31, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 18:32:48, Eventassword Error, Door:entry, Card No.:1240
2005/11/11 18:35:32, Event:Access, Door:entry, Card No.:2271, Description:266:55250
2005/11/11 18:35:38, Event:Access, Door:entry, Card No.:2271, Description:266:55250
2005/11/11 18:36:01, Event:Access, Door:entry, Card No.:2271, Description:266:55250
2005/11/11 18:55:41, Event:Access, Door:entry, Card No.:2271, Description:266:55250
2005/11/11 18:57:41, Event:Access, Door:entry, Card No.:2271, Description:266:55250
2005/11/11 19:06:25, Event:Access, Door:entry, Card No.:2345, Description:266:55732

when i open this file in list box us you notice there is some text row that is diff. from the others. that specific row i want to delete because when i save this file in access if there is some row that are diff to the other is creates a error.. thanks
Reputation Points: 13
Solved Threads: 1
Junior Poster in Training
royaloba is offline Offline
54 posts
since Sep 2006
Sep 11th, 2006
0

Re: How to delete a row in text file?

Can you define which ones should be removed? Anything that is not:
2005/11/11 17:50:58, Event:Access, Door:entry, Card No.:2345, Description:266:55732
Right?
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Sep 12th, 2006
0

Re: How to delete a row in text file?

yes sir, anything that not match the format

2005/11/11 17:50:58, Event:Access, Door:entry, Card No.:2345, Description:266:55732

thanks
Reputation Points: 13
Solved Threads: 1
Junior Poster in Training
royaloba is offline Offline
54 posts
since Sep 2006
Sep 12th, 2006
0

Re: How to delete a row in text file?

Read each line
If it contains "Event:Access, Door:entry, Card No.", write it to the file
If not, don't
If not at end-of-file, go back to read the next line
Moderator
Reputation Points: 3281
Solved Threads: 896
Posting Sage
WaltP is offline Offline
7,753 posts
since May 2006
Sep 12th, 2006
0

Re: How to delete a row in text file?

thanks to your reply,but sir a want a sample code..thanks
Reputation Points: 13
Solved Threads: 1
Junior Poster in Training
royaloba is offline Offline
54 posts
since Sep 2006
Sep 12th, 2006
0

Re: How to delete a row in text file?

Click to Expand / Collapse  Quote originally posted by royaloba ...
thanks to your reply,but sir a want a sample code..thanks
Please sir, first answer these questions:
1) do you know how to open a file?
2) Do you know how to read the file one line at a time?
3) Do you know how to check if a line (string) contains specific substring?

And finally
4) Are you trying to learn how to program, or have the program written for you?
Moderator
Reputation Points: 3281
Solved Threads: 896
Posting Sage
WaltP is offline Offline
7,753 posts
since May 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: create os with visual basic
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: please help! vb6 & excel





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC