Results 1 to 4 of 4

Thread: Nice and Easy I reckon

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2000
    Posts
    39

    Talking

    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.


  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    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?

  3. #3
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    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]

  4. #4

    Thread Starter
    Member
    Join Date
    Aug 2000
    Posts
    39

    Thumbs up

    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
  •  



Click Here to Expand Forum to Full Width