Sei sulla pagina 1di 1

procedimiento keypress

If Char.IsLetter(e.KeyChar) Then
e.Handled = False
ElseIf Char.IsControl(e.KeyChar) Then
e.Handled = False
ElseIf Char.IsSeparator(e.KeyChar) Then
e.Handled = False
Else
e.Handled = True
End If

Private Sub TextBox1_KeyPress(ByVal sender As Object, _


ByVal e As
System.Windows.Forms.KeyPressEventArgs) _
Handles TextBox1.KeyPress
If InStr(1, "0123456789," & Chr(8), e.KeyChar) = 0 Then
e.KeyChar = ""
End If
End Sub

keydow
If Not((e.KeyValue >= 65 And e.KeyValue <= 90)OrElse (e.KeyValue >= 37 And
e.KeyValue <= 40) OrElse (e.KeyValue = 192) OrElse (e.KeyValue = 8 OrElse
e.KeyValue = 46)) Then

e.Handled = True

e.SuppressKeyPress = True

EndIf

Private Sub textbox1_KeyPress(ByVal sender As Object, ByVal e As


System.Windows.Forms.KeyPressEventArgs) Handles textbox1.KeyPress
If Not IsNumeric(e.KeyChar) Then
e.Handled = True
End If
End Sub

Si quieres aceptar solo letras mayusculas y minusculas escribe lo siguiente


f InStr("1234567890", e.KeyChar) = 0 Then
e.KeyChar = Chr(0)
End If

Dim X As Integer
X = Asc(e.KeyChar)
If ((X >= 65 And X <= 90) Or (X >= 97 And X <= 122)) = 0 Then
e.KeyChar = Chr(0)
End If

Potrebbero piacerti anche