|
-
Oct 29th, 2000, 11:34 PM
#1
Thread Starter
PowerPoster
I thought I asked this question before, but I searched the whole forum and couldn't find the post. I'll ask again and hope that someone can help me.
How can I save a listbox as a textfile? I am saving a playlist for an MP3 player and I need to save each item in the list on it's own line in the textbox. I'm already able to load files into the textbox, I just want to save it.
Thanks
-
Oct 29th, 2000, 11:38 PM
#2
Code:
Public Sub List_Load(TheList As ListBox, FileName As String)
'Load a file to a list box
On Error Resume Next
Dim TheContents As String
Dim fFile As Integer
fFile = FreeFile
Open FileName For Input As fFile
Do
Line Input #fFile, TheContents$
TheList.Additem TheContents$
Loop Until EOF(fFile)
Close fFile
End Sub
Public Sub List_Save(TheList As Listbox, FileName As String)
'Save a listbox as FileName
On Error Resume Next
Dim Save As Long
Dim fFile As Integer
fFile = FreeFile
Open FileName For Output As fFile
For Save = 0 To TheList.ListCount - 1
Print #fFile, TheList.List(Save)
Next Save
Close fFile
End Sub
-
Oct 29th, 2000, 11:41 PM
#3
Member
private sub cmdSave_Click()
Dim Search as Integer
Open "YourFile" for output as #1
for search = 0 to list1.Listcount-1
print #1, list1.list(search)
next search
close #1
-
Oct 30th, 2000, 12:02 AM
#4
Thread Starter
PowerPoster
Thanks!
Thanks for responding so fast. I uesd your code Matthew and it works really good. D.paulson, I tried your code, and it worked, but I used Matthew's because I could use the public subs with more than one button. Thanks for posting though.
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
|