Results 1 to 6 of 6

Thread: way to add items to list box permanently

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2003
    Posts
    31

    way to add items to list box permanently

    Hi,
    Is there a way to add item to a list box (know how to do this)
    and have that new item remain in the listbox next time the App is loaded ?

    Thanks in advance.

  2. #2
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    You need to store the information somewhere. So store the listitems in a file, or in the registry.
    The registry would probably be easiest. Try using SaveSetting() and GetSetting()
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  3. #3
    New Member
    Join Date
    Jul 2003
    Location
    Phoenx, AZ
    Posts
    15

    db or registry

    Either the registry or a database. Code can't store once the program is closed. Registry will probably be the easiest. Database be better if your going to run the app on mulitple machines and need the same info.

  4. #4
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427
    Originally posted by plenderj
    ...The registry would probably be easiest. Try using SaveSetting() and GetSetting()
    Click the Use SaveSetting and GetSetting to store and retrieve data from the Registry link in my signature.

  5. #5

  6. #6
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    I'd suggest putting the data in a UDT, you could take other info as well this way(checked, tags, etc).

    As a UDT, Binary read/write access will do most the work for you!

    VB Code:
    1. Private Type tList
    2.      lstText as String
    3.      lstChecked as Boolean
    4.      lngTag as Long
    5. End Type
    6.  
    7. Private List() as tList
    8.  
    9. Open file for Binary as #1
    10. Put 1,, List
    11. Close #1

    The only problem here is knowing the number of records.

    You could either loop til EOF, redimming along the way. Or write a long with the number of indices at the start of the file. Read it, set bounds, and do it in one chunk(probably faster).

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