Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> Visual Basic >> Snippet

Textbox - automatically highlight content


'Put this in the GotFocus event
text1.selstart = 0
text1.sellength = Len(text1.sellength)

'Or use this as a subroutine that all textboxes can call
Me .ActiveControl.SelStart = 0
Me .ActiveControl.SelLength = Len( Me .ActiveControl.Text)