HOLA. TENGO ESTE CODIGO. DICHO CODIGO ME PERMITE QUE EN UN TEXTO EL PRIMER ESPACIO SEA UNA LETRA Y DE ALLI EN ADELANTE SOLO NUMEROS. PERO LO QUE REALMENTE QUIERO EN ESE CASO ES QUE. COMO DIJE ANTERIORMENTE ME PERMITA LETRAS, PERO QUE SOLO ME PERMITA DOS. EJEMPLO.. LA V O LA E. SI ALGUIEN SABE POR FA SE LOS AGRADEXCO.
Código:
If KeyAscii = 10 Then Exit Sub ' tecla retroceso
If Chr(KeyAscii) = vbCr Or Chr(KeyAscii) = vbTab Then
' tecla ENTER o TAB, antes de pasar el foco al siguiente control
' verificamos el número de caracteres
If Len(txtCedula) <> 10 Then ' (letra + guión + 6 caracteres)
KeyAscii = 0
Else
SendKeys "{Tab}"
End If
Exit Sub
End If
If Len(txtCedula) = 0 Then
' 1er dígito, lo convertimos a mayúsculas
KeyAscii = Asc(UCase(Chr(KeyAscii)))
If KeyAscii > 64 And KeyAscii < 91 Then ' entre ese rango todas son mayusculas
' carácter correcto, le añadimos el guión y nos posicionamos al final
txtCedula.Text = Chr(KeyAscii) & "-"
txtCedula.SelStart = 3
End If
' eliminamos la pulsación de tecla
KeyAscii = 0
' si se ha eliminado el guión (con la tecla de retroceso)
' convertimos el carácter digitado en un guión
ElseIf Len(txtCedula) = 1 Then KeyAscii = 45
Else
' sólo números
If Not IsNumeric(Chr(KeyAscii)) Then KeyAscii = 0
End If