Título: ayuda con codigo que pille
Publicado por: CARRY-ON en 6 Octubre 2007, 19:47 pm
Sub Text1_Keypress(KeyAscii As Integer) If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = 127 Or KeyAscii = 8 Then ' El 48 es 0 y el 57 es 9, 127 es SUPR y 8 es Backspace Exit Sub Else MsgBox "Solo números para registrar el valor a pagar sin puntos, " & _ "ni comas, ni cualquier caracter especial!!" End If End Sub
pille este codigo para validar que solo ingrese numero el problema que al mandar el mensaje la letra sigue en el txt y no se borra probe poniendo al final del msgbox text1="" pero no se borra
Título: Re: ayuda con codigo que pille
Publicado por: papanoel_devacaciones en 6 Octubre 2007, 20:12 pm
no se, yo para mi cliente uso este Sub TextIP_Keypress(KeyAscii As Integer) Static LastText As String Static SecondTime As Boolean If Not SecondTime Then With TextIP If .Text Like "*[!0-9]*" Then MsgBox "Solo numeros para registrar el valor a pagar sin puntos, " & _ "ni comas, ni cualquier caracter especial!!" SecondTime = True .Text = LastText .SelStart = LastPosition Else End If End With End If End Sub SecondTime = False
y me sirve bastante.. ( lo he modificado un poquito) :xD Saludos
Título: Re: ayuda con codigo que pille
Publicado por: CARRY-ON en 6 Octubre 2007, 20:19 pm
pero limpia el txt??
Título: Re: ayuda con codigo que pille
Publicado por: papanoel_devacaciones en 6 Octubre 2007, 20:20 pm
Aunque parezca que no...si lo hace :xD :xD
Saludos
Título: Re: ayuda con codigo que pille
Publicado por: APOKLIPTICO en 6 Octubre 2007, 23:18 pm
Sub Text1_Keypress(KeyAscii As Integer) If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = 127 Or KeyAscii = 8 Then ' El 48 es 0 y el 57 es 9, 127 es SUPR y 8 es Backspace KeyAscii = 0 'Esto anula el caracter incorrecto. Exit Sub Else MsgBox "Solo números para registrar el valor a pagar sin puntos, " & _ "ni comas, ni cualquier caracter especial!!" End If End Sub
|