Hi,
Basically, I want to be able to save information entered into a listbox in the registry, and I want to retrieve that information from the registry into a listbox. Can anyone suggest the code?
Please help :D
Regards,
Phil
Printable View
Hi,
Basically, I want to be able to save information entered into a listbox in the registry, and I want to retrieve that information from the registry into a listbox. Can anyone suggest the code?
Please help :D
Regards,
Phil
Sure!!!
This works for one item, if you want it for all items just put a loop.Code:Private Sub Form_Load()
List1.AddItem GetSetting(App.Title, "Options", "ListBox")
End Sub
Private Sub Form_Unload(Cancel As Integer)
SaveSetting(App.Title, "Options", "ListBox", List1.List(0))
End Sub
If it are alot of items I suggest using a textfile instead, it keeps your registry clean and is easier to manage.
I agree, a textfile would probably be easier to use. Do you think that you could specify the code for using a textfile for multiple items, each on their own line.
Cheers,
Phil
Sure!!
Haven't tested it but it should work.Code:'Make sure the file exists before trying this code
Private Sub Form_Load()
Dim File$, fn%, tmp$
File = App.Path & "\list.txt"
fn = FreeFile
Open File For Input As #fn
Do While Not(Eof(fn))
Line Input #fn, tmp
List1.AddItem tmp
Loop
Close #fn
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim File$, fn%, x%
File = App.Path & "\list.txt"
fn = FreeFile
Open File For Output As #fn
For x = 0 To List1.ListCount - 1
Print #fn, List1.List(x)
Next x
Close #fn
End Sub