Click to See Complete Forum and Search --> : saving list
Help ME
Nov 26th, 1999, 01:45 PM
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.
Aaron Young
Nov 26th, 1999, 02:03 PM
Take a look at the GetSetting and SaveSetting VB Functions used for storing Data in the Registry..
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
aarony@redwingsoftware.com
adyoung@win.bright.net
Help ME
Nov 27th, 1999, 01:47 AM
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
Aaron Young
Nov 27th, 1999, 11:06 AM
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
aarony@redwingsoftware.com
adyoung@win.bright.net
Help ME
Nov 28th, 1999, 11:18 AM
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.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.