Vyndrox Posted January 8, 2004 Posted January 8, 2004 ***************a part of the source code***************** Dim file As New System.IO.StreamWriter(filename) For i = 0 To UBound(sFiles) file.WriteLine(sFiles(i)) Next file.Close() ListBox1.Items.Clear() ListBox1.Items.Add("The text file is written in the same directory as this executable, as " & filename) btnSave.Enabled = False btnShowFiles.Text = "Show Directory Files" btnShowFiles.Focus() ListBox1.Items.Add(Application.StartupPath & "\" & filename) Catch ArgumentExep As System.ArgumentException MsgBox(ArgumentExep.Message & vbLf & "Don't use illegal characters," & vbLf & "and wait 5 to 10 seconds to save to another file.") Catch IOExep As System.IO.IOException MsgBox(IOExep.Message & vbLf & "Wait 5 to 10 seconds and then save again, with another filename.") End Try I need the program to writes all the lines in the listbox to the .txt and not only the result. Maybe one of u guys have a solution for it. Quote
Administrators PlausiblyDamp Posted January 8, 2004 Administrators Posted January 8, 2004 what is the variable sFiles? Is that being written to a file for a reason? If you want to save and load items from a ListBox why are you clearing it and adding non-listbox information to it? You should be able to save the list with code similar to Dim ListFile as new System.IO.StreamWriter("Random file name here.txt") Dim i as string for each i in listbox1.items listfile.writeline(i) next listfile.close() Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Vyndrox Posted January 8, 2004 Author Posted January 8, 2004 Here i got the source for you, it's a bit complicated to explain :p Quote
Vyndrox Posted January 8, 2004 Author Posted January 8, 2004 (edited) Your solution is workin' properly, thanks Edited January 8, 2004 by Vyndrox Quote
Administrators PlausiblyDamp Posted January 8, 2004 Administrators Posted January 8, 2004 Is the file open? Is it the same file you were using in Dim file As New System.IO.StreamWriter(filename)? If so you will need to do a file.Close(). Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Vyndrox Posted January 8, 2004 Author Posted January 8, 2004 i now removed the old lines with yours and it's workin perfectly Quote
Vyndrox Posted January 8, 2004 Author Posted January 8, 2004 Maybe you also know a solution to : http://www.xtremedotnettalk.com/t81533.html :D Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.