|
-
Aug 24th, 2000, 09:35 AM
#1
Thread Starter
Member
Anyone have a good routine to capture the contents of a list box and dump it to a text file ?
EG: I need to capture the actual displayed data of a listbox, not just selected items, but all items.
-
Aug 24th, 2000, 09:39 AM
#2
Code:
Public Sub SaveLBContents(lstBox As ListBox, FileName As String)
Dim iFile%, i%, iCount%
iCount = lstBox.ListCount - 1
iFile = FreeFile
Open FileName For Output As #iFile
For i = 0 To iCount
Print #iFile, lstBox.List(i)
Next
Close #iFile
End Sub
Or do you mean a listbox from any application and not only your own?
-
Aug 24th, 2000, 09:46 AM
#3
Frenzied Member
Getting all the items in a list is easy, you just loop through them,
Code:
Private Sub Command1_Click()
For i = 0 To List1.ListCount - 1
MsgBox List1.List(i)
Next i
End Sub
will put up a message for every item in the list, I'm not too hot on file handling, but there's some good tutorials Here
[Edited by Sam Finch on 08-24-2000 at 11:22 AM]
-
Aug 24th, 2000, 10:17 AM
#4
Thread Starter
Member
Thanks Sam, and once again Joacim thanks. Both replies were very useful, one of my co-workers has absconded with all my vb manuals as well as my MSDN discs so I couldn't find the syntax.
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
|