Como hago para que solo admita numeros ?
Puede reacomodar tú código de esta manera sin tantos IfCódigo: Textsaludos :hola:
Private Sub text1_keypress(keyascii As Integer) If keyascii = 8 Then '8 es la tecla backspace GoTo salir End If If (keyascii < 48 Or keyascii > 57) Then keyascii = 0 End If salir: End Sub
:ph34r: ademas de que hay un signo igual (=) extra, lo probe y no acepta la tecla BACKSPACE porque deberia ser asi:
Puede reacomodar tú código de esta manera sin tantos IfCódigo: Text
Private Sub text1_keypress(keyascii As Integer) If (keyascii < 48 Or keyascii > 57) And KeyAscii == 8 Then keyascii = 0 End If salir: End Sub
También puedes usar la función IsNumeric(). :whistling:Asi es
Sorry :( :( Es que estoy jugando con Python y me estoy apegando a su sintaxis :comp: :comp:Cita de: "RadicalEd":ph34r: ademas de que hay un signo igual (=) extra, lo probe y no acepta la tecla BACKSPACE porque deberia ser asi:
Puede reacomodar tú código de esta manera sin tantos IfCódigo: Text
Private Sub text1_keypress(keyascii As Integer) If (keyascii < 48 Or keyascii > 57) And KeyAscii == 8 Then keyascii = 0 End If salir: End Sub Código: Text
Private Sub text1_keypress(keyascii As Integer) If (keyascii < 48 Or keyascii > 57) And KeyAscii <> 8 Then keyascii = 0 End If salir: End Sub