|
-
Aug 26th, 2005, 10:18 PM
#1
Thread Starter
Addicted Member
[RESOLVED]Saving the contents of a Listbox to a txt
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.
Last edited by Garrett19212; Aug 26th, 2005 at 10:41 PM.
-
Aug 26th, 2005, 10:30 PM
#2
Junior Member
Re: Saving the contents of a Listbox to a txt
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
-
Aug 26th, 2005, 10:32 PM
#3
Fanatic Member
Re: Saving the contents of a Listbox to a txt
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
Did you find a post in this thread useful? Please click Rate This Post.
-
Aug 26th, 2005, 10:40 PM
#4
Thread Starter
Addicted Member
Re: Saving the contents of a Listbox to a txt
Thank you both works great, I use search just can never find what I want, I suck with keywords.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|