复制操作应该是复制当前选区而不是整个文本框内容,粘贴应该是将剪帖板内容插入到当前光标所在位置,而不是将文本框原有内容彻底覆盖,另外,通常当Text1没选中文字时,要使复制按钮Command1不可用
Private Sub Command1_Click()
Clipboard.SetText Text1.SelText
End Sub
Private Sub Command2_Click()
If Len(Clipboard.GetText) Then
Text1.SelText = Clipboard.GetText
End If
End Sub
Private Sub Form_Load()
Command1.Enabled = False
End Sub
Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
Command1.Enabled = Text1.SelLength > 0
End Sub
Private Sub Text1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Butt Then
Command1.Enabled = Text1.SelLength > 0
End If
End Sub
比如Text1的内容为abc,而当前只选中了第一个字符a
那么Text1.text表示文本框的全部内容,即abc
而Text1.SelText表示文本框中当前选中的内容,即a--selText是select text(选中文字)的缩写