CodeItBetter Programming Another VB Programming Blog

How to select all text with Ctrl+A in a text box

Posted on January 4, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
'Controls - How to select all text with Ctrl+A in a text box
'In the TextBox's KeyPress event handler, check for the Ctrl-A key combination.
'If the user presses Ctrl-A, use the TextBox's SelStart and SelLength properties
'to select all of the control's text.

Private Sub Text1_KeyPress(KeyAscii As Integer)
    Const ASC_CTRL_A As Integer = 1
 
    If KeyAscii = ASC_CTRL_A Then
        Text1.SelStart = 0
        Text1.SelLength = Len(Text1.Text)
    End If
End Sub
Filed under: Controls Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.