PDA

View Full Version : VB.Net Question: How do I take a value like...


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?

Mr NO-IT-AHL
03-25-2007, 06:00 AM
make that a method and just call the method everytime u type something in on the textfields

Richard H
03-25-2007, 07:00 AM
check out http://www.pscode.com for great source code samples.