|
-
Nov 26th, 1999, 02:45 PM
#1
Thread Starter
Junior Member
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.
-
Nov 26th, 1999, 03:03 PM
#2
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]
-
Nov 27th, 1999, 02:47 AM
#3
Thread Starter
Junior Member
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
-
Nov 27th, 1999, 12:06 PM
#4
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]
-
Nov 28th, 1999, 12:18 PM
#5
Thread Starter
Junior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|