Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Visual Basic
Expertise: Beginner
Feb 24, 2000



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Use an Easier Autohighlight Method

Most of us have a routine we call to autohighlight the entire contents of a textbox when it receives focus. And most of us type the name of the textbox when we pass it to this routine. Instead of typing the control's name in each GotFocus event, you can use this sub to highlight the currently active textbox on the passed form. Place this code in a module:
Sub HiLite(frm As Form)
	frm.ActiveControl.SelStart = 0
	frm.ActiveControl.SelLength = _
End Sub
Then place this line of code in your textbox control's GotFocus() event:
Private Sub Text1_GotFocus()
	HiLite Me
End Sub
Using this code, you can forget about typing your controls' names over and over.
Achim Wengeler
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date