Click here to Skip to main content
15,887,304 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how can i save a listbox's items as text wherever i want to.

I can do this
VB
Dim ItemArray(Me.ListBox1.Items.Count - 1) As Object
      Me.ListBox1.Items.CopyTo(ItemArray, 0)
      Dim Data As String = Join(ItemArray, Environment.NewLine)

      My.Computer.FileSystem.WriteAllText("C:\Users\Juljan\Desktop\text.txt", Data, False)

but if i dont want to save it there i have to build the program again with different code..
Posted
Updated 12-Dec-11 18:23pm
v2
Comments
[no name] 13-Dec-11 0:23am    
EDIT: added "pre" tag

1 solution

Are you serious about re-building the program? There are no situations where a hard-coded path name can be useful — at all. (I would advice you not to use any immediate constants, except a very special ones line null, 0 or 1; not even "", because you should use string.Empty instead.)

In your case, you can use FileSaveDialog. I don't give you exact fully qualified type name and MSDN reference just because you did not tag the UI library you want to use, so please Google for the one you would use with your library.

Good luck,
—SA
 
Share this answer
 
Comments
Juljano 13-Dec-11 0:54am    
sorry but i have been awake almost 20 hours now and i have been searching about this all this time , i am a litle bit tired... what do you mean by UI library?
Can you give me some sample code for VB 2010 Express cause i think this is the last thing i need to so create my program.My english suck by the way sorry about that ^^ Thanks anyway :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900