Option ExplicitPrivate Sub Command1_Click() Text1.SelStart = 0 Text1.SelLength = Len(Text1.Text) Text1.SetFocus End Sub
同意楼上,如果你是想把文本框里的内容复制到剪贴板,你可以用APPLICATION.COPY
private sub text1_Gotfocus() with text1 .selstart=0 .sellengh=len(text1.text) end withprivate sub command1_click() text1.setfocus text1_gotfocus end sub
把代码写在GotFocus事件中!Private Sub Text1_GotFocus() Text1.SelStart = 0 Text1.SelLength = Len(Text1.Text) End Sub
不过在某个命令结束后:TEXT1。SETFOUCE
我本来也是用你着段代码
可好象不行,我要把TEXT里的内容选中(即成兰色)
SendKeys "{Home}+{End}"
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
Text1.SetFocus
End Sub
with text1
.selstart=0
.sellengh=len(text1.text)
end withprivate sub command1_click()
text1.setfocus
text1_gotfocus
end sub
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
End Sub