foto51 0 Report post Posted February 14, 2007 Hello, I have a project that I am doing. I have a list box that you can enter data in, and I need it to have the ability to save that list into a text file (Names.txt). The txt file should have each entry on it's own line. Any help would be appreciated. Share this post Link to post Share on other sites
Galahad 0 Report post Posted February 17, 2007 I'm not sure about Vb.Net, I haven't touched it in couple of years, but I can give you code, how it would look in VB6, and you can go from there: Dim i As LongOpen "Names.txt" For Output As #1 For i = 0 To List1.ListCount - 1 Print #1, List1.List(i) Next iClose #1 And that's it... I believe it should be fairly simple in Vb.Net too... Probably very similar... Share this post Link to post Share on other sites
Galahad 0 Report post Posted March 26, 2007 OK, I'm sure you already found what you were looking for, but I'll post an example code, of how to write text files in VB.NET... Maybe someone in the future would find it usefull: Imports SystemImports System.IOPublic Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim f As StreamWriter, i As Long, obj As Object For i = 1 To 10 ListBox1.Items.Add("Item " & i.ToString) Next i f = New StreamWriter("C:\Test.txt") For i = 0 To ListBox1.Items.Count - 1 f.WriteLine(ListBox1.Items.Item(i).ToString) Next i f.Close() End SubEnd Class That's the full working code, just copy and paste it in your project, and voila... Hope it helped a bit Share this post Link to post Share on other sites