|
|
Title | Let the user press Ctrl-A to select all of the text in a TextBox |
Description | This example shows how to let the user press Ctrl-A to select all of the text in a TextBox in Visual Basic 6. |
Keywords | ctrl-A, control-A, select text |
Categories | Strings, Controls |
|
|
When the TextBox's KeyPress event sees the Ctrl-A key code (1), it calls subroutine SelectAllText. That routine sets the control's SelStart property to 0 and its SelLength property to the length of the text in the control.
|
|
Private Sub Text2_KeyPress(KeyAscii As Integer)
Const CTRL_A As Integer = 1
If KeyAscii = CTRL_A Then SelectAllText Text2
End Sub
Private Sub SelectAllText(ByVal txt As TextBox)
txt.SelStart = 0
txt.SelLength = Len(txt.Text)
End Sub
|
|
|
|
|
|