This is a tutorial or tips To Copy selected item from listbox in to Clipboard.
Follow this step :
1. Add a ListBox (List1 is created by default)
2. Make a Text Box (Text1 is created by default.)
3. Set its MultiLine property to True and its ScrollBars property to 2-Vertical.
4. Make Command Button control (Command1 is created by default
5. Set its Caption property to "Copy to Clipboard".
Type the following code :
Private Sub Command1_Click()
CopyListbox
End Sub
Private Sub CopyListbox()
Dim CopytoClip As String
Dim I As Integer
Clipboard.Clear
CopytoClip = ""
For I = 0 To List1.ListCount - 1
If List1.Selected(I) Then
CopytoClip = CopytoClip & List1.List(I) & Chr$(13) & Chr$(10)
End If
Next I
Clipboard.SetText CopytoClip
End Sub
5. Set its Caption property to "Copy to Clipboard".
Type the following code :
Private Sub Command1_Click()
CopyListbox
End Sub
Private Sub CopyListbox()
Dim CopytoClip As String
Dim I As Integer
Clipboard.Clear
CopytoClip = ""
For I = 0 To List1.ListCount - 1
If List1.Selected(I) Then
CopytoClip = CopytoClip & List1.List(I) & Chr$(13) & Chr$(10)
End If
Next I
Clipboard.SetText CopytoClip
End Sub
0 comments:
Posting Komentar