|
-
April 27th, 2001, 10:24 AM
#1
Object persistence
How can I save the state of an object (namely, the contents of a listbox) when the application terminates. I'm writing an app that updates a database with a specified file. As the user opens the files and updates the db, the list of files he's updated will stay in the listbox - however, when the application is exited, the list of files is lost. I need to save this list and present them to the user the next time the application is run so he knows the last file he updated. Any suggestions?
Brian
-
April 27th, 2001, 10:49 AM
#2
Re: Object persistence
You can save the contents of the list box to the .ini file. When you start your app, first read ini file to the list box.
Iouri Boutchkine
[email protected]
-
April 27th, 2001, 11:18 AM
#3
Re: Object persistence
You can use a list box to save the contents of the list box and retrieve them later.
private Sub Form_Load()
Dim aLine as string
Open App.Path & "\saved.txt" for input as #1
Do While Not EOF(1)
Line input #1, aLine
List1.AddItem aLine
Loop
Close #1
End Sub
private Sub Form_Unload()
Dim i as Integer
Open App.Path & "\saved.txt" for Output as #1
for i = 0 to List1.ListCount - 1
print #1, List1.List(i)
next
close #1
End Sub
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
|