Results 1 to 5 of 5

Thread: Remebering...

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2002
    Posts
    22

    Remebering...

    Hey can I get it so when a person adds an entry into a listbox, then closes the program then opens it again, the entry will still be there?

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Write the entry to the listbox, and the machines registry, at the same time.

    When the program opens, populate your listbox, and read the registry entries, and make the appropriate setting.

    Are you familiar with SaveSetting and GetSetting? If not, I can provide you with examples.

    Another option would be to write the entry to the listbox, and a local Db table, at the same time.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jun 2002
    Posts
    22
    Nope not familiar with those.

  4. #4
    Addicted Member
    Join Date
    Jul 2002
    Posts
    234
    You could use the registry, but Microsoft recommends not using it for these types of purposes. The easiest way to do what you as is to simply write your data to a file (choose your extension) and then re-read the data when you project reopens. Something like this:

    VB Code:
    1. '=============================
    2. ' Reload your list
    3. '=============================
    4. Private Sub Form_Load()
    5.  
    6.    Dim FF as long
    7.    Dim sData as String
    8.    
    9.    if Len(Trim$(DIR$(App.Path & "\list.dat")))<>0 then
    10.        List1.Clear  
    11.        FF = FreeFile
    12.        Open App.Path & "\list.dat" for Input As FF
    13.            Do while not EOF(FF)
    14.                 Line Input #FF, sData
    15.                 list1.Add sData
    16.            Loop
    17.         Close FF
    18.     End if
    19.  
    20. End Sub  
    21.  
    22. '===================================
    23. ' Save the List on Unload
    24. '===================================
    25. Private Sub Form_Unload(Cancel As Integer)
    26.    Dim FF as long
    27.    Dim sData as string
    28.    Dim x as long
    29.  
    30.    if Len(Trim$(Dir$(App.Path & "\list.dat")))<>0 then
    31.       Kill App.Path & "\list.dat"
    32.    end if
    33.  
    34.    FF = FreeFile
    35.  
    36.    Open App.Path & "\list.dat" for Binary as FF
    37.    
    38.    For x = 0   to (List1.listcount -1)
    39.         sData = List1.list(x) & vbCRLF
    40.         Put #FF, , sData
    41.    Next
    42.  
    43.    Close FF
    44.  
    45. End Sub

  5. #5
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well

    Then you could always store the information in a database....
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

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