|
-
Jan 25th, 2002, 04:55 PM
#1
Thread Starter
Hyperactive Member
Deleting from a file!
Hey what's up, i was just wondering if i can lets say remove just one specific line from a txt file. so lets say its like this
"Bla", "Ble", "Blue"
"Pel", "Mel", "Melll"
lets say i want to remove just the "Bla","Ble","Blue" from lets say a file calle Check.dat, is there a way i can do that, or no . Thx your your help again.
-
Jan 25th, 2002, 05:32 PM
#2
Frenzied Member
The way I've done something like this in the past is to open the file and then open a second, new file. Read every line from the original into the second, new file except for the line you want to delete. You then Kill the original file and rename (Name) the new file as the original.
Greg
Free VB Add-In - The Reference Librarian
Click Here for screen shot and download link.
-
Jan 25th, 2002, 05:34 PM
#3
Try this thread:
http://www.vbforums.com/showthread.p...hreadid=135822
I found it by doing a search with the key "remove one line"
-
Jan 25th, 2002, 05:56 PM
#4
Thread Starter
Hyperactive Member
Thank!
Thank you. Wow alot harder then i thought.
-
Jan 25th, 2002, 06:04 PM
#5
strText = "Delete lines containing this text"
Open "TextFile.txt" For Input As #1
Open "NewFile.txt" For Output As #2
Do While Not EOF(1)
Line Input #1, strTemp1
If InStr(1,strTemp1,strText) = 0 Then Print #2, strTemp1
Loop
Close #1,#2
Kill "TextFile.txt"
Name "NewFile.txt" As "TextFile.txt"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|