|
-
Sep 12th, 2002, 05:50 PM
#1
Thread Starter
Junior Member
Remebering...
Hey can I get it so when a person adds an entry into a listbox, then closes the program then opens it again, the entry will still be there?
-
Sep 12th, 2002, 06:09 PM
#2
Write the entry to the listbox, and the machines registry, at the same time.
When the program opens, populate your listbox, and read the registry entries, and make the appropriate setting.
Are you familiar with SaveSetting and GetSetting? If not, I can provide you with examples.
Another option would be to write the entry to the listbox, and a local Db table, at the same time.
-
Sep 12th, 2002, 06:47 PM
#3
Thread Starter
Junior Member
Nope not familiar with those.
-
Sep 12th, 2002, 06:55 PM
#4
Addicted Member
You could use the registry, but Microsoft recommends not using it for these types of purposes. The easiest way to do what you as is to simply write your data to a file (choose your extension) and then re-read the data when you project reopens. Something like this:
VB Code:
'=============================
' Reload your list
'=============================
Private Sub Form_Load()
Dim FF as long
Dim sData as String
if Len(Trim$(DIR$(App.Path & "\list.dat")))<>0 then
List1.Clear
FF = FreeFile
Open App.Path & "\list.dat" for Input As FF
Do while not EOF(FF)
Line Input #FF, sData
list1.Add sData
Loop
Close FF
End if
End Sub
'===================================
' Save the List on Unload
'===================================
Private Sub Form_Unload(Cancel As Integer)
Dim FF as long
Dim sData as string
Dim x as long
if Len(Trim$(Dir$(App.Path & "\list.dat")))<>0 then
Kill App.Path & "\list.dat"
end if
FF = FreeFile
Open App.Path & "\list.dat" for Binary as FF
For x = 0 to (List1.listcount -1)
sData = List1.list(x) & vbCRLF
Put #FF, , sData
Next
Close FF
End Sub
-
Sep 12th, 2002, 08:10 PM
#5
PowerPoster
Well
Then you could always store the information in a database....
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
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
|