phrozen_wolf
03-24-2007, 11:45 PM
...e.Keychar, and run it through a Function and return the result? I have 24+ text boxes on my form and I have them limited to only accepting A-Z a-z and Backspace using this code:
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If Not ( _
(e.KeyChar >= "a" And e.KeyChar = "A" And e.KeyChar = (TextBox1.MaxLength - 1) _
And e.KeyChar ControlChars.Back Then SendKeys.Send("{TAB}")
End If
End Sub
But I don't want to have to put that in each of the txtbox KeyPress events. Is there a way to send the e.KeyChar result to another sub and then back?
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If Not ( _
(e.KeyChar >= "a" And e.KeyChar = "A" And e.KeyChar = (TextBox1.MaxLength - 1) _
And e.KeyChar ControlChars.Back Then SendKeys.Send("{TAB}")
End If
End Sub
But I don't want to have to put that in each of the txtbox KeyPress events. Is there a way to send the e.KeyChar result to another sub and then back?