evento keydown - valor de la tecla nulo?
hola, mi problema es el siguiente:
Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 8
Case Is < 48, Is > 57
KeyAscii = 0
End Select
End Sub
El codigo de arriba me permite solo ingresar numeros en el TextBox text1 utilizando el evento KeyPress.
Pero el problema que tengo es: como hago esto en el evento KeyDown, he intentado con el siguiente codigo:
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case 8
Case Is < 48, Is > 57
KeyCode = 0
End Select
End Sub
Pero no pasa nada. El problema creo que esta en el "KeyCode=0".
No se alguien me pude ayudar.
Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 8
Case Is < 48, Is > 57
KeyAscii = 0
End Select
End Sub
El codigo de arriba me permite solo ingresar numeros en el TextBox text1 utilizando el evento KeyPress.
Pero el problema que tengo es: como hago esto en el evento KeyDown, he intentado con el siguiente codigo:
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case 8
Case Is < 48, Is > 57
KeyCode = 0
End Select
End Sub
Pero no pasa nada. El problema creo que esta en el "KeyCode=0".
No se alguien me pude ayudar.
este es el codigo que utilizo yo para validaciones, siempre en el keypress, prueba si te funciona en keydown.
strValido es la cadena que contiene todos los caracteres que estan permitidos ingresar.
Dim strValido As String
strValido = "0123456789"
KeyAscii = Asc(UCase(Chr(KeyAscii)))
If KeyAscii > 26 Then
If InStr(strValido, Chr(KeyAscii)) = 0 Then
KeyAscii = 0
End If
End If
strValido es la cadena que contiene todos los caracteres que estan permitidos ingresar.
Dim strValido As String
strValido = "0123456789"
KeyAscii = Asc(UCase(Chr(KeyAscii)))
If KeyAscii > 26 Then
If InStr(strValido, Chr(KeyAscii)) = 0 Then
KeyAscii = 0
End If
End If
