Ver Mensaje Individual
  #4 (permalink)  
Antiguo 30/05/2004, 18:07
sakateuna
 
Fecha de Ingreso: marzo-2004
Mensajes: 34
Antigüedad: 21 años, 1 mes
Puntos: 0
haz esto!

ambos codigos pegalos en un modulo

Para comprobar que se ingresen numeros:

Public Function Numeros(Tecla As Integer) As Integer
Dim strValido As String
strValido = "0123456789"
If Tecla > 26 Then
'compara los numeros ke hay en la variable strValido _
con el numero ingresado(Tecla)
'si el numero ingresado(Tecla) no esta en la variable strValido entonces _
Tecla = 0, la funcion Chr convierte el numero a ascii
If InStr(strValido, Chr(Tecla)) = 0 Then
Tecla = 0
End If
End If
Numeros = Tecla
End Function

Para comprobar que se ingresen letras:

Public Function VLetras(Tecla As Integer) As Integer
Dim strValido As String
'letras no validas: .*-}¿'!%&/()=?¡]¨*[Ññ;:_ áéíó
strValido = "qwertyuioplkjhgfdsazxcvbnmQWERTYUIOPASDFGHJKLZXCV BNM, "
If Tecla > 26 Then
If InStr(strValido, Chr(Tecla)) = 0 Then
Tecla = 0
End If
End If
VLetras = Tecla
End Function

y Listo....luego llamas las funciones de la siguiente forma

Private Sub txtCiudad_KeyPress(KeyAscii As Integer)
KeyAscii = VLetras(KeyAscii)
End Sub

Espero te sirva