How can I save the contents of a listbox to a txt file?
Meaning by each line of a listbox is a line in the txt file.
Printable View
How can I save the contents of a listbox to a txt file?
Meaning by each line of a listbox is a line in the txt file.
You can do it like this:
VB Code:
Open FileName for Output as #1 'Opens the file to write For i = 0 to List1.Listcount -1 Line = List1.List(i) ' Reads the list-item Print #1, Line & vbCrLf ' Writes it in the file Next i Close #1 ' Closes the file
Hope it helps ;)
Here's one way:
VB Code:
Open "c:\path\filename.txt" for output as #1 For x = 0 to list1.listcount - 1 print #1, list1.list(x) next Close #1
By the way, I found this by a search through the forums ;)
Thread I found it in:
http://vbforums.com/showthread.php?t...s+listbox+file
Thank you both works great, I use search just can never find what I want, I suck with keywords.