VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Highlights the text in any textbox that receives focus!

by Jerry Tilsley (1 Submission)
Category: Custom Controls/Forms/Menus
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 3rd April 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Highlights the text in any textbox that receives focus!

Rate Highlights the text in any textbox that receives focus!



'function to see the magic work.  Examples are listed later in this code.
Public Function txtGotFocus()
For i = 0 To Form1.Count - 1
    Set obj = Form1.ActiveControl
    If TypeOf obj Is TextBox Then
            obj.SelStart = 0
            obj.SelLength = Len(obj.Text)
    End If
Next i
End Function

'This demostrates the use of TextBox arrays
Private Sub Text1_GotFocus(Index As Integer)
    txtGotFocus
End Sub

'This demostrates the use of just normal multiple TextBoxes
'Just attach the "txtGotFocus" command to any textbox GotFocus event.
Private Sub Text2_GotFocus()
    txtGotFocus
End Sub




Download this snippet    Add to My Saved Code

Highlights the text in any textbox that receives focus! Comments

No comments have been posted about Highlights the text in any textbox that receives focus!. Why not be the first to post a comment about Highlights the text in any textbox that receives focus!.

Post your comment

Subject:
Message:
0/1000 characters