Buscar en el sitio

Contacto

Danny

962318754

blackorwhite_dm@hotmail.com

Seleccionar texto en textbox

03.11.2010 19:24

Con esta función seleccionaremos todo el texto de un textbox.


Public Sub TextSelected()
Dim i As Integer
Dim oMyTextBox As Object

Set oMyTextBox = Screen.ActiveControl
If TypeName(oMyTextBox) = "TextBox" Then
i = Len(oMyTextBox.Text)
oMyTextBox.SelStart = 0
oMyTextBox.SelLength = i
End If
End Sub


Simplemente añade la función a tu proyecto y llámala desde el evento GotFocus del TextBox.

Private Sub Text1_GotFocus()
TextSelected
End Sub