Private Sub Text1_GotFocus() '当Text1获得焦点时,最后一个字符串被选中
Text1.SelStart = InStrRev(Text1.Text, " ")
Text1.SelLength = Len(Text1.Text)
Text1_MouseUp 0, 0, 0, 0 '同时把选中内容放入Text2
End Sub
Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
Text1_MouseUp 0, 0, 0, 0 '如果选择是通过键盘完成的,也放入Text2中
End Sub
Private Sub Text1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) '这个则是处理用鼠标来选定的情况,不管是双击还是拖动选择均可
If Text1.SelText <> "" Then Text2.Text = Text1.SelText '如果Text1存在被选中的字符就放入Text2中
End Sub