是要处理文本吗?
'添加窗体Form1,文本框Text1,按钮Command1,Command2,Command3,然后添加如下代码:
Private Sub Form_Load()
Command1.Caption = "剪切"
Command2.Caption = "复制"
Command3.Caption = "粘贴"
End Sub
'剪切
Private Sub Command1_Click()
Clipboard.Clear
Clipboard.SetText Text1.SelText
Text1.SelText = ""
End Sub
'复制
Private Sub Command2_Click()
Clipboard.Clear
Clipboard.SetText Text1.SelText
End Sub
'粘贴
Private Sub Command3_Click()
Text1.SelText = Clipboard.GetText
End Sub
呵呵,一下是我自己的代码。
新建一个工程,textbox、picturebox、commandbutton控件各一个,默认属性。
Private Sub Command1_Click()
Text1.Text = Clipboard.GetText
Picture1.Picture = Clipboard.GetData
End Sub
Private Sub Form_Click()
' 定义位图各种格式。
Dim ClpFmt, Msg ' 声明变量。
On Error Resume Next ' 设置错误处理。
If Clipboard.GetFormat(vbCFText) Then ClpFmt = ClpFmt + 1
If Clipboard.GetFormat(vbCFBitmap) Then ClpFmt = ClpFmt + 2
If Clipboard.GetFormat(vbCFDIB) Then ClpFmt = ClpFmt + 4
If Clipboard.GetFormat(vbCFRTF) Then ClpFmt = ClpFmt + 8
Select Case ClpFmt
Case 1
Msg = "剪贴版上只有文本。"
Case 2, 4, 6
Msg = "剪贴版上只有位图。"
Case 3, 5, 7
Msg = "剪贴版上有文字和位图。"
Case 8, 9
Msg = "剪贴版上有富文本。"
Case Else
Msg = "剪切版上无内容。"
End Select
MsgBox Msg ' 显示信息。
End Sub
复制的代码:
Private
Sub
mnuEditCopy_Click()
On
Error
Resume
Next
Clipboard.SetText
ActiveForm.rtfText.SelRTF
End
Sub
剪贴
Private
Sub
mnuEditCut_Click()
On
Error
Resume
Next
Clipboard.SetText
ActiveForm.rtfText.SelRTF
ActiveForm.rtfText.SelText
=
vbNullString
End
Sub
粘贴
Private
Sub
mnuEditPaste_Click()
On
Error
Resume
Next
ActiveForm.rtfText.SelRTF
=
Clipboard.GetText
End
Sub