create un modulo
Module Module1
Public Function SoloNumeros(ByVal keyascii As Short) As Short
keyascii = Asc(UCase(Chr(keyascii)))
If InStr("0123456789", Chr(keyascii)) = 0 Then
SoloNumeros = 0
Else
SoloNumeros = keyascii
End If
If keyascii = 8 Then SoloNumeros = keyascii
If keyascii = 13 Then SoloNumeros = keyascii
End Function
Public Function SoloNumerosDecimales(ByVal keyascii As Short) As Short
keyascii = Asc(UCase(Chr(keyascii)))
If InStr("0123456789", Chr(keyascii)) = 0 Then
SoloNumerosDecimales = 0
Else
SoloNumerosDecimales = keyascii
End If
If keyascii = 8 Then SoloNumerosDecimales = keyascii
If keyascii = 13 Then SoloNumerosDecimales = keyascii
If keyascii = 44 Then SoloNumerosDecimales = keyascii
If keyascii = 46 Then SoloNumerosDecimales = keyascii
' End If
End Function
Public Function SoloLetras(ByVal keyascii As Short) As Short
keyascii = Asc(UCase(Chr(keyascii)))
If InStr("ABCDEFGHIJKLMNOPQRSTUVWXYZ ", Chr(keyascii)) = 0 Then
SoloLetras = 0
Else
SoloLetras = keyascii
End If
If keyascii = 8 Then SoloLetras = keyascii
If keyascii = 13 Then SoloLetras = keyascii
End Function
End Module
en el evento keypress de los tetbox pones esto
'textbox acepta solo Letras
Private Sub txt_Ate_Pagante_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txt_Ate_Pagante.KeyPress
Dim keyasci As Short = CShort(Asc(e.KeyChar))
keyasci = CShort(SoloLetras(keyasci))
If keyasci = 0 Then
e.Handled = True
MessageBox.Show("Solo Ingrese Letras", "Sistema XXXXXXXXXX", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
End Sub
'texto que acepta solo numeros
Private Sub txt_Ate_NumdocPagante_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txt_Ate_NumdocPagante.KeyPress
Dim keyasci As Short = CShort(Asc(e.KeyChar))
keyasci = CShort(SoloNumeros(keyasci))
If keyasci = 0 Then
e.Handled = True
MessageBox.Show("Solo Ingrese Numeros", "Sistema XXXXX", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
End Sub