Click here to Skip to main content
15,568,965 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello All,

I need an code that will help me to export values from three listbox to excel or text file by using save file dialog.

What I have tried:

Dim w as io.streamwriter
Dim I as integer
W = new iO.streamwriter ("c:\" & ".text")
For I = 0 to listbox1.items.count -1
Updated 13-Mar-22 4:13am

Your filename is C:\.text. That's not legal in windows.

Why is it people do this:
"C:\" & ".text"

and not just skip the concatenation entirely since it's not needed:
Share this answer
Elias Ar 13-Mar-22 1:34am    
Your reply doesn't help me, I know I should put the file name but I'm asking for something else, How I can save an Excel or Text file by using the save file dialog, please read the post three times before replying.
Take a look at MSDN documentation:
SaveFileDialog Class (System.Windows.Forms) | Microsoft Docs[^]
How to: Write Text to Files with a StreamWriter - Visual Basic | Microsoft Docs[^]

If you would like to write data into Excel file, i'd suggest to install EPPlus NuGet package[^]. Here is CP article with example code: How to Use EPPlus in VB[^]
Share this answer

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