Results 1 to 2 of 2

Thread: listbox to clipboard

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Posts
    3

    Post

    I'm using vba6 with quattro pro
    and am new to visual basic. I'd like
    to copy the contents of a listbox
    (or combobox) to the clipboard but
    just cant figure it out.
    Help or suggestions would be appreciated.
    Thanks,
    Doug Anderson

  2. #2
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523

    Post

    To add it to the clipboard you could use this code:
    Code:
    Option Explicit
    Dim I As Integer
    
    Private Sub Command1_Click()
        For I = 1 To List1.ListCount
            If I = 1 Then
                '//you can command this out
                '//without this line VB adds an extra empty line to the Clipboard
                Clipboard.SetText List1.List(I - 1)
            Else
                Clipboard.SetText (Clipboard.GetText & vbCrLf & List1.List(I - 1))
            End If
        Next I
    End Sub
    HTH


    ------------------
    Visual Basic Programmer
    ------------------
    PolComSoft
    You will hear a lot about it.


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