Hi,
I have this problem, I know how to save a listbox. but i dnt know how to save this listbox with the name of a selected item from another listbox.
to save it, i usually use this code
Dim w As New IO.StreamWriter("test.txt")
Dim i As Integer
For i = 0 To ListBox1.Items.Count - 1
w.WriteLine(ListBox1.Items.Item(i))
Next
w.Close()
and to load a text into a listbox, i use this one
Dim r As New IO.StreamReader("test.txt")
While (r.Peek() > -1)
ListBox1.Items.Add(r.ReadLine)
Label1.Text = ListBox1.Items.Count
End While
r.Close()
End If
Now i was wondering if there would be a possibility to load or save this listbox1 with the name of the selected item from another listbox (listbox2)
I was thinking something like that
for saving:
Dim w As New IO.StreamWriter(textbox2.SelectedText)
for laoding:
Dim r As New IO.StreamReader("textbox2.SelectedText")
Of course It didnt work, i just wanted to show you my idea. And even if it would work, i have also to to tell my program that it should save in a txt File. But thats not the main problem right now. First off all i would appreciate it so much, if someone could help me here.
Summary: Save or load content of ListBox1 into a text file with the name of that item which is selected in TextBox2
I have this problem, I know how to save a listbox. but i dnt know how to save this listbox with the name of a selected item from another listbox.
to save it, i usually use this code
Dim w As New IO.StreamWriter("test.txt")
Dim i As Integer
For i = 0 To ListBox1.Items.Count - 1
w.WriteLine(ListBox1.Items.Item(i))
Next
w.Close()
and to load a text into a listbox, i use this one
Dim r As New IO.StreamReader("test.txt")
While (r.Peek() > -1)
ListBox1.Items.Add(r.ReadLine)
Label1.Text = ListBox1.Items.Count
End While
r.Close()
End If
Now i was wondering if there would be a possibility to load or save this listbox1 with the name of the selected item from another listbox (listbox2)
I was thinking something like that
for saving:
Dim w As New IO.StreamWriter(textbox2.SelectedText)
for laoding:
Dim r As New IO.StreamReader("textbox2.SelectedText")
Of course It didnt work, i just wanted to show you my idea. And even if it would work, i have also to to tell my program that it should save in a txt File. But thats not the main problem right now. First off all i would appreciate it so much, if someone could help me here.
Summary: Save or load content of ListBox1 into a text file with the name of that item which is selected in TextBox2