|
-
Mar 21st, 2000, 08:41 AM
#1
Thread Starter
New Member
I am trying to update and delete records, using Visual Basic, from a file I have called "items.csv"
I displayed the current records in a listbox and I was wondering how you use VB and delete records from the file I called "items.csv"
example data in "items.csv"
item# A B C D
0142 123 32 12 YES
1111 111 222 0 NO
.
1234 123 123 0 NO
.
.
and so on
How do you go about deleting item# 1234 in the file item.csv
can anyone help????
-
Mar 21st, 2000, 08:46 AM
#2
Fanatic Member
Yes actually i do.
Well u have to either rewrite the entire file, excluding that 1 record. Or use the
open for binary
method, but you'll have to know the exact lenght of the string.
-
Mar 21st, 2000, 08:56 AM
#3
Hyperactive Member
Each of the elements in the listbox has a number associated to it such that if you got the value of listbox.listindex you would find that it is a number from 0 to listbox.listcount - 1.
This is the line number you want to delete so what you do is simple.
Code:
1. Open a temporary file
2. For each of the items in the list box
3. If this item is NOT the selected item
4. Write this line to the temporary file
5. Next item in the list box
6. Close the File
7. Delete the Old File
8. Rename the temporary file as the Old File
This is the pseudo-code for it... see if you can work out what the code looks like.
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
|