|
-
Jan 20th, 2007, 09:21 AM
#1
Thread Starter
Addicted Member
[2005] managing a text database saving issue
i have a .txt database for a game and i am making a program to manage this database.... the format is like this
1,"John","usa"
2,"billy","australia"
3,"joe","malaysia"
.
.
.
.
.
there is about 15000 entries!!!!
i read the .txt file line by line and i use split to get the id,country and name of each entry and put it on a listbox... encapsulating the id,country,name in an object... and i add each object in the listbox...
then i can select the entries from the listbox and the name,id and country for selecteditem of listbox are displayed in textboxes....
i allow users to be able to change the country,name from the textbox and i record the change in the listbox....
Now here come the problem..... when the user has made all necessary changes, he/she has to save it back to the .txt file!!! this process take a very very long time to complete as i have to loop through all the listbox,store it in a variable and write the variable in the .txt file!!!! this is very slow..
here's how i save to the .txt..i store id,name and country in a class "entry"
VB Code:
private class entry
public id as integer,name ,country as string
public sub new(byval i as integer,byval nm as string,byval c as string)
id=i
name=nm
country=c
end sub
end class
private sub save()
dim i as integer,e as entry,out as string=""
for i=0 to list1.items.count-1
e=ctype(list1.items.item(i),entry)
out=e.id & """" & e.name & """," & """" & e.country & """" & vbnewline
next i
end sub
as i said there are 15000 entries!!! i can't use a database this file is need by a game....
i have tried to use sortedlist used to save the changes but it is slow too!!!!
HELP PLZ!!!!
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
|