|
-
Nov 12th, 2000, 09:02 AM
#1
Thread Starter
New Member
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 
Regards,
Phil
-
Nov 12th, 2000, 09:11 AM
#2
Frenzied Member
Sure!!!
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
This works for one item, if you want it for all items just put a loop.
If it are alot of items I suggest using a textfile instead, it keeps your registry clean and is easier to manage.
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Nov 12th, 2000, 09:17 AM
#3
Thread Starter
New Member
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
-
Nov 12th, 2000, 09:29 AM
#4
Frenzied Member
Sure!!
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
Haven't tested it but it should work.
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
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
|