Results 1 to 2 of 2

Thread: [2005] managing a text database saving issue

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    128

    [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:
    1. private class entry
    2.   public id as integer,name ,country as string
    3.  
    4.   public sub new(byval i as integer,byval nm as string,byval c as string)
    5.      id=i
    6.      name=nm
    7.      country=c
    8.   end sub
    9.  
    10. end class
    11.  
    12. private sub save()
    13.   dim i as integer,e as entry,out as string=""
    14.   for i=0 to list1.items.count-1
    15.        e=ctype(list1.items.item(i),entry)
    16.        out=e.id & """" & e.name & """," & """" & e.country & """" & vbnewline
    17.   next i
    18. 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!!!!

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    128

    Re: [2005] managing a text database saving issue

    i find what caused that much delay!!! it was the variable i used to store each entry..... i have write directly to .txt file now and it is very fast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width