AllAPI Network - The KPD-Team

 
Allapi Network
 API-Guide
 ApiViewer

 API List

 
API Resources
 Tips & Tricks
 VB Tutorials
 Error Lookup
 
Misc Stuff
 VB examples
 VB Tools
 VB Links
 Top Downloads
 
This Site
 Search Engine
 Contact Form
 

Donate to AllAPI.net

Selecting all text on focus

When working with data entry controls, the current value in the control often needs to be selected when the control received focus. This allows the user to immediately begin typing over any previous value. Here's a quick subroutine to do just that:

Code

Public Sub SelectAll(Editctr As Control)
    With Editctr
        .SelStart = 0
        .SelLength = Len(Editctr.Text)
        .SetFocus
    End With
End Sub   

Use

If the GotFocus event of an input control, put the following code:

Call SelectAll(controlname)

For example, if the input control was called txtHello, the code in its GotFocus event would be:

Call SelectAll(txtHello)

 

 


Copyright © 1998-2007, The Mentalis.org Team - Privacy statement
Did you find a bug on this page? Tell us!
This site is located at http://allapi.mentalis.org/