Results 1 to 5 of 5

Thread: saving list

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 1999
    Posts
    20

    Post

    how do i make it where there add an item . and next time there open the program that item there added to the list box is still there. where it save the changes to the list box.

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    Take a look at the GetSetting and SaveSetting VB Functions used for storing Data in the Registry..
    Code:
    Private Sub List1_DblClick()
        'Add Item from List1 to List2
        List2.AddItem List1
    End Sub
    
    Private Sub Form_Load()
        Dim iIndex As Integer
        Dim sItem As String
        
        'Create some Dummy List Items for List1
        For iIndex = 1 To 10
            List1.AddItem "Item " & iIndex
        Next
        
        'Load any Saved List Items from the Registry
        iIndex = 1
        Do
            sItem = GetSetting(App.Title, "List Items", iIndex, "")
            If Len(sItem) Then
                List2.AddItem sItem
                iIndex = iIndex + 1
            End If
        Loop While Len(sItem)
        
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
        Dim iIndex As Integer
        'Save any Items in List2 to the Registry for Next Time.
        For iIndex = 1 To List2.ListCount
            Call SaveSetting(App.Title, "List Items", iIndex, List2.List(iIndex - 1))
        Next
    End Sub
    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Nov 1999
    Posts
    20

    Post

    well. i make the exe to see if it would work. ok iopen the exe up. and added 100 items. then close it and reopen it. it the item where not there. can you please till me what wrong.

    thank you

  4. #4
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    Did you copy the Code I posted exactly? Onto a Form with 2 Listboxes?
    If so, it should work.

    All it's doing is When the Form Loads, it checks the Registry for Any entries in the Key List Items, if there are any it loads them into List2.

    When the Form is Unloaded, any Items in List2 are saved out to the Registry under the Key List Items.

    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Nov 1999
    Posts
    20

    Post

    i paste that code right in vb. and i did add ever thing that was i list1 to list 2 and it did not work. i do not know it it does not work.

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