Question save each selecteditem into a text file (not save all items in listbox

gozo12

New member
Joined
Feb 28, 2012
Messages
1
Programming Experience
Beginner
hello
save each selecteditem into a text file
not save all items in the listbox
only the item u want
this code will save all items , but i want only save items that u selected it . into same text file

VB.NET:
        Dim i As Integer
        w = New IO.StreamWriter("e:\test.txt")
        For i = 0 To ListBox1.Items.Count - 1
            'w.WriteLine(ListBox1.SelectedItem(i))
            w.WriteLine(ListBox1.Items.Item(i))
        Next


        w.Close()
Thanks
jackie
 
You can use the SelectedItems property. It will give you a collection of all selected items.

Public ReadOnly Property SelectedItems As _
ListBox1.SelectedObjectCollection
 

Latest posts

Back
Top