I have my listbox on my form. I want to be able to save whatever is in the collection to a .txt file. Then re-open it later in inside the program, and have my collection remain the same.
For example:
my llistbox collection as 3 items in it.
Apples
Grapes
Pears
I would like it to save to the text file.then when i open it again, the listbox would take each line and set it as a item in the list box.
so it would read the 1st line of text in teh txt file, and set that as the 1st item.
then it would take the 2nd line of text from the text file and set the 2nd item in the listbox.
and so on.
My attempt:
Sub Savedocument() Dim outputfile As System.IO.StreamWriter outputfile = System.IO.File.CreateText(documentname) outputfile.Write(lstStatuslist.Items) outputfile.Close() isChanged = False End Sub If ofdOpen.ShowDialog = DialogResult.OK Then documentname = ofdOpen.FileName inputfile = System.IO.File.OpenText(documentname) lstStatuslist.Text = inputfile.ReadToEnd inputfile.Close() End If
Please help me out. As you can probally see im lost =)
This post has been edited by JMDizzle: 22 May 2008 - 08:44 PM

New Topic/Question
Reply




MultiQuote



|