How to Automatically Select or Highlight Text Box Upon Focus (110394)
The information in this article applies to:
- Microsoft Visual Basic Standard Edition for Windows 3.0
- Microsoft Visual Basic Professional Edition for Windows 3.0
This article was previously published under Q110394 SUMMARY
The sample program below automatically selects (highlights) all text in a
text box whenever the text box gets the focus. This is done by using the
SelStart and SelLength properties in the GetFocus event for the text box.
Automatic highlighting is useful in data entry boxes where you want to give
the user the option to quickly overwrite the existing contents by pressing
any character key.
To avoid overwriting the highlighted text after giving focus to the text
box, the user can single-click the text, or press an arrow (direction) key
or cursor-movement key (such as END or HOME) to remove the highlighting
from the text and allow editing.
Modification Type: | Major | Last Reviewed: | 10/29/2003 |
---|
Keywords: | KB110394 |
---|
|