0
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

3
Contributors
3
Replies
5
Views
5 Years
Discussion Span
Last Post by M.Waqas Aslam
2

simply use this code:

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

Edited by renzlo: n/a

Votes + Comments
sorry if you feel bad :(
0

thanks :)
how to mark this post as Solved ?

Edited by gozo12: n/a

0

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.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.