请问vb怎样编写代码把复制,剪切,粘贴东西到别处
答案:2 悬赏:10
解决时间 2021-02-07 12:38
- 提问者网友:江山如画
- 2021-02-06 22:05
请问vb怎样编写代码把复制,剪切,粘贴东西到别处
最佳答案
- 二级知识专家网友:懂得ㄋ、沉默
- 2021-02-06 23:23
如果焦点在Text1的话单击粘帖是不是自动粘帖到Text2?
不知道这样行吗?
我这是不论焦点在哪个Text
只要Text中含有内容时,复制才可以用。
其实这也是按照Windows的设计。
有内容时,复制按钮可以用。(同理,有内容时,剪切才可以用)当触发了复制事件后,粘帖按钮才可以用。
Dim which As Integer, T As Integer
Private Sub copy_Click()
If which = 1 Then
T = Text1.Text
ElseIf which = 2 Then
T = Text2.Text
End If
End Sub
Private Sub cut_Click()
If which = 1 Then
T = Text1.Text
Text1.Text = ""
ElseIf which = 2 Then
T = Text2.Text
Text2.Text = ""
End If
End Sub
Private Sub edit_Click()
If which = 1 Then
If Text1.Text = "" Then
cut.Enabled = False
copy.Enabled = False
Else
cut.Enabled = True
copy.Enabled = True
End If
ElseIf which = 2 Then
If T = "" Then
cut.Enabled = False
copy.Enabled = False
Else
cut.Enabled = True
copy.Enabled = True
End If
End If
If T = "" Then
paste.Enabled = False
Else
paste.Enabled = True
End If
End Sub
Private Sub paste_Click()
If which = 1 Then
Text1.Text = Text1 + T
ElseIf which = 2 Then
Text2.Text = Text2 + T
End If
End Sub
Private Sub Text1_GotFocus() '本过程的作用是:当焦点在Text1中时,which = 1
which = 1
End Sub
Private Sub Text2_GotFocus() '本过程的作用是:当焦点在Text2中时,which = 2
which = 2
End Sub
不知道这样行吗?
我这是不论焦点在哪个Text
只要Text中含有内容时,复制才可以用。
其实这也是按照Windows的设计。
有内容时,复制按钮可以用。(同理,有内容时,剪切才可以用)当触发了复制事件后,粘帖按钮才可以用。
Dim which As Integer, T As Integer
Private Sub copy_Click()
If which = 1 Then
T = Text1.Text
ElseIf which = 2 Then
T = Text2.Text
End If
End Sub
Private Sub cut_Click()
If which = 1 Then
T = Text1.Text
Text1.Text = ""
ElseIf which = 2 Then
T = Text2.Text
Text2.Text = ""
End If
End Sub
Private Sub edit_Click()
If which = 1 Then
If Text1.Text = "" Then
cut.Enabled = False
copy.Enabled = False
Else
cut.Enabled = True
copy.Enabled = True
End If
ElseIf which = 2 Then
If T = "" Then
cut.Enabled = False
copy.Enabled = False
Else
cut.Enabled = True
copy.Enabled = True
End If
End If
If T = "" Then
paste.Enabled = False
Else
paste.Enabled = True
End If
End Sub
Private Sub paste_Click()
If which = 1 Then
Text1.Text = Text1 + T
ElseIf which = 2 Then
Text2.Text = Text2 + T
End If
End Sub
Private Sub Text1_GotFocus() '本过程的作用是:当焦点在Text1中时,which = 1
which = 1
End Sub
Private Sub Text2_GotFocus() '本过程的作用是:当焦点在Text2中时,which = 2
which = 2
End Sub
全部回答
- 1楼网友:闲懒诗人
- 2021-02-07 00:32
Clipboard.SetText text1.text'把text1的内容到剪贴板
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯