-
April 25th, 2002, 09:02 AM
#1
Copy from list box
A book I was looking at implied you could copy the information from a list box to the clipboard with code. Does anyone have a knowledge of this? Thanks for your time.
-
April 25th, 2002, 09:10 AM
#2
Re: Copy from list box
You could do something like this
Dim Mystr as string
for i = 0 to List1.ListCount - 1
Mystr = Mystr & List1.List(i) & vbCrLf
next
Clipboard.Clear
Clipboard.SetText Mystr
-
April 25th, 2002, 09:44 AM
#3
Re: Copy from list box
'The code below clear Clipboard and copy selected items from a listbox to it.
private Sub Command1_Click()
Dim i, strToCopy as string, SelNum as Long
strToCopy = ""
SelNum = 0
for i = 0 to List1.ListCount - 1
If List1.Selected(i) then
SelNum = SelNum + 1
strToCopy = strToCopy & List1.List(i) & IIf(SelNum < List1.SelCount, vbCrLf, "")
End If
next
Clipboard.Clear
Clipboard.SetText strToCopy
End Sub
'The code below clear Clipboard and copy all items in a listbox to it.
private Sub Command2_Click()
Dim i as Long, strToCopy as string
strToCopy = ""
for i = 0 to List1.ListCount - 2
strToCopy = strToCopy & List1.List(i) & vbCrLf
next
strToCopy = strToCopy & List1.List(i)
Clipboard.Clear
Clipboard.SetText strToCopy
End Sub
Help us improve our answers by rating them.
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
|