Just wanted to know how to select the text in a text box when that text box get the focus.
Thanks
Hurgh
Printable View
Just wanted to know how to select the text in a text box when that text box get the focus.
Thanks
Hurgh
Try this:
Code:Private Sub Text1_GotFocus()
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
Text1.SetFocus
End Sub
Matthew - Shouldn't the last line ("Text1.SetFocus") be omitted? Otherwise, won't the GotFocus event will execute in an endless loop?
Code:Private Sub Text2_GotFocus()
Text2.SelStart = 0
Text2.SelLength = Len(Text2.Text)
End Sub
It shoul be omitted. But it wont get in to an endless loop because the object allready has the focus so even if you call SetFocus the GotFocus event wont be fired.Quote:
Originally posted by BruceG
Matthew - Shouldn't the last line ("Text1.SetFocus") be omitted? Otherwise, won't the GotFocus event will execute in an endless loop?