Protected by

The goat will get ya.

 

Site Navigation
Home
Up

Hosting by Yahoo!

 


 

VB Tip 1

 

Global Textbox Selection

 A global function that selects the text in the current text box when it gains focus.

In a public module place the following function:

   
    Public Sub SelectAll(ByRef txtControl As TextBox)

        If Len(txtControl.Text & "x") > 1 Then
            txtControl.SelStart = 0
            txtControl.SelLength = Len(txtControl.Text)
        End If

    End Sub

   

       

Then in the 'GotFocus' Event of a Textbox Control (in this example named Text1) type in this one liner:

 

    Private Sub Text1_GotFocus()
        '
        SelectAll Text1

    End Sub

 

Now... any time Text1 obtains the focus, all existing text in the textbox is selected.


Hit Counter

This page lasted edited on 10/20/2005 04:40 PM