Public Function SoloCaracteres(ByVal strFiltro As String, ByVal KeyAscii As Integer, ByVal Largo As Integer, ByVal LargoPermitido As Integer, ByVal SelStr As Integer) As Integer
If InStr(strFiltro, Chr(KeyAscii)) = 0 Then
SoloNumeros = 0
Else
SoloNumeros = KeyAscii
End If
If SoloNumeros <> 0 Then
If (Largo + 1) > LargoPermitido And SelStr = 0 Then
SoloNumeros = 0
End If
End If
If KeyAscii = 8 Then SoloNumeros = KeyAscii ' borrado atras
If KeyAscii = 13 Then SoloNumeros = KeyAscii ' return
End Function
Private Sub txtCedula_KeyPress(KeyAscii As Integer)
'Este ejemplo únicamente te permite escribir números del 0 al 9
' y letras V,E,J, e y minúscula.
KeyAscii = SoloCaracteres("VEJy-0123456789", KeyAscii, Len(txtCedula.Text), 10, txtCedula.SelLength)
If KeyAscii = 13 Then Call cmdingresar_Click
End Sub
Puede que te sirva.