Private Sub save_Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

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



    End Sub

this code will save all items in listbox
but i want
when u click an item(selecteditem) then u click save button its only save that item,

and when u want to save another item then it save the two item in the same txt fie

etc : in listbox1 it have items "s1" , "s2" "s3"

when u select s1 then u click save it

so the txt file will have items s1 only

and when u select s2 and click the save button then in txt file u have 2 items
s1
s2
and so on

simply use this code:

Dim w As New IO.StreamWriter("e:\test.txt", True)
        w.WriteLine(ListBox1.SelectedItem, True)
        w.Close()

Edited 4 Years Ago by renzlo: n/a

Comments
sorry if you feel bad :(

thanks :)
how to mark this post as Solved ?

Edited 4 Years Ago by gozo12: n/a

where we type post there is a link mark this thread solved , click it thread is solved , and please @renzlo that i am just come and got a solved thread , i am just telling him.

Regards

This question has already been answered. Start a new discussion instead.