Select Case KeyAscii
Case 48 To 57 'asciis de numeros 0 a 9
Case 8 'ascii de tecla backspace
Case Else
'si no está dentro de ese rango, no permite el ingreso
KeyAscii = 0
End Select
End If
Private Sub Text1_KeyPress(KeyAscii As Integer)
KeyAscii = numeros(KeyAscii)
End Sub
Public Function numeros(Tecla As Integer) As Integer
Dim strValido As String
strValido = "0123456789"
If Tecla > 26 Then
If InStr(strValido, Chr(Tecla)) = 0 Then
Tecla = 0
End If
End If
numeros = Tecla
End Function