Results 1 to 3 of 3

Thread: [RESOLVED] list box

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2006
    Location
    Greater Manchester, UK
    Posts
    476

    Resolved [RESOLVED] list box

    How do you save and load the contents of a list box to the registry.

    To load i tried.
    VB Code:
    1. lstPC.List = GetSetting("NETWORK", "CLIENT", "UserList", "")

    and to save i tried.
    Code:
    SaveSetting "NETWORK", "CLIENT", "Userlist", lstPC.List

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: list box

    VB Code:
    1. Private Sub Form_Load()
    2. Dim strParts() As String
    3. Dim lngIndex As Long
    4.  
    5. strParts = Split(GetSetting("NETWORK", "CLIENT", "UserList", ""), "||")
    6.  
    7. For lngIndex = 0 To UBound(strParts)
    8.     lstPC.AddItem strParts(lngIndex)
    9. Next
    10. End Sub
    11.  
    12. Private Sub Form_Unload(Cancel As Integer)
    13. Dim strAccum As String
    14. Dim lngIndex As Long
    15.  
    16. For lngIndex = 0 To lstPC.ListCount - 1
    17.     strAccum = strAccum & lstPC.List(lngIndex) & "||"
    18. Next
    19.  
    20. strAccum = Left$(strAccum, Len(strAccum) - 2) ' if you use a one character delimiter instead of || then change to -1
    21. SaveSetting "NETWORK", "CLIENT", "Userlist", strAccum
    22.  
    23. End Sub
    BTW vbcode tags look better than code tags.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2006
    Location
    Greater Manchester, UK
    Posts
    476

    Re: list box

    Thanks
    If your question is answered then mark your thread RESOLVED and give credit to whoever answered it.

    If you fail, try and try again, its the only way to success.

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