关于选中文本的问题
来源:百度知道 编辑:UC知道 时间:2024/05/15 13:11:28
请问我这段代码为什么不能选中文本框的文字?
Private Sub Command1_Click()
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
End Sub
Private Sub Form_Load()
Text1.Text = "12345"
End Sub
Private Sub Command1_Click()
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
End Sub
Private Sub Form_Load()
Text1.Text = "12345"
End Sub
因为Text1没有获得焦点
这样就可以了
Private Sub Command1_Click()
Text1.SetFocus '-----使Text1获得焦点
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
End Sub
Private Sub Form_Load()
Text1.Text = "12345"
End Sub