Clipboard 对象提供对系统 Clipboard 的访问。语法Clipboard说明Clipboard 对象用于操作剪贴板上的文本和图形。它使用户能够复制、剪切和粘贴应用程序中的文本和图形。在复制任何信息到 Clipboard 对象中之前,应使用 Clear 方法清除 Clipboard 对象中的内容,例如 Clipboard.Clear。注意所有 Windows 应用程序共享 Clipboard 对象,因此当切换到其它应用程序时,剪贴板内容会改变。Clipboard 对象可包含多段数据,只要每段数据的格式不同。例如,可用 SetData 方法把位图以 vbCFDIB 格式放到 Clipboard 中,接着再用 SetText 方法以 vbCFText 格式将文本放到 Clipboard 中。然后用 GetText 方法检索文本或用 GetData 方法检索图形。当用代码或菜单命令把另一段数据放到 Clipboard 下列代码为使用任何标准控件,提供了通用的“剪切”、“复制”和“粘贴”命令。Private Sub mnuCopy_Click ()
Clipboard.Clear
If TypeOf Screen.ActiveControl Is TextBox Then
Clipboard.SetText Screen.ActiveControl.SelText
ElseIf TypeOf Screen.ActiveControl Is ComboBox Then
Clipboard.SetText Screen.ActiveControl.Text
ElseIf TypeOf Screen.ActiveControl Is PictureBox _
Then
Clipboard.SetData Screen.ActiveControl.Picture
ElseIf TypeOf Screen.ActiveControl Is ListBox Then
Clipboard.SetText Screen.ActiveControl.Text
Else
'对其它控件没有意义的动作。
End If
End Sub
Clipboard.Clear
If TypeOf Screen.ActiveControl Is TextBox Then
Clipboard.SetText Screen.ActiveControl.SelText
ElseIf TypeOf Screen.ActiveControl Is ComboBox Then
Clipboard.SetText Screen.ActiveControl.Text
ElseIf TypeOf Screen.ActiveControl Is PictureBox _
Then
Clipboard.SetData Screen.ActiveControl.Picture
ElseIf TypeOf Screen.ActiveControl Is ListBox Then
Clipboard.SetText Screen.ActiveControl.Text
Else
'对其它控件没有意义的动作。
End If
End Sub
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货