This makes it easy to overwrite the text. You can do this easily by adding a couple of lines to the GotFocus event procedure:
Sub Text1_GotFocus ()
Text1.SelStart = 0
Text1.SelLength = 65535
End Sub
Notice that the length value for SelLength is 65535, the maximum length allowed in a Text Box. This forces Visual Basic to use the actual length of the text as the SelLength.
This tip is reprinted from the VB Tips & Tricks Volume 1 book.
Discover more from dotNetTips.com
Subscribe to get the latest posts sent to your email.
