thugster69
Active member
- Joined
- Jun 17, 2010
- Messages
- 35
- Programming Experience
- Beginner
Is there any possibility that I can put this large chunk of code to a function so that I can call and verify the input without having to repeat the code for every textbox.keyPress event.
Here it is:
Here it is:
VB.NET:
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
With e
If IsNumeric(.KeyChar) Or .KeyChar = "[" Or .KeyChar = "]" Or .KeyChar = ";" Or .KeyChar = ":" _
Or .KeyChar = "'" Or .KeyChar = "<" Or .KeyChar = "," Or .KeyChar = ">" Or .KeyChar = "\" _
Or .KeyChar = "|" Or .KeyChar = "." Or .KeyChar = "?" Or .KeyChar = "/" Or .KeyChar = "-" _
Or .KeyChar = "_" Or .KeyChar = "+" Or .KeyChar = "=" Or .KeyChar = "!" Or .KeyChar = "@" _
Or .KeyChar = "#" Or .KeyChar = "$" Or .KeyChar = "%" Or .KeyChar = "^" Or .KeyChar = "&" _
Or .KeyChar = "*" Or .KeyChar = "(" Or .KeyChar = ")" Or .KeyChar = "{" Or .KeyChar = "}" Then
e.Handled = True
End If
End With
End Sub