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?
Printable View
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?
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.
Nope not familiar with those.
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
Then you could always store the information in a database....