Using the keypress event, I am limiting the characters that can be entered into a textbox to numeric values, backspace, and the decimal key. Somehow my code to allow the decimal character (46) to be entered is preventing me from exiting the textbox when making edits containing a decimal in my application - focus is stuck on this textbox. However it does allow me to enter the decimal character as desired. When I comment the "ElseIf e.KeyChar = Chr(46)" lines out, the textbox behaves fine...but the decimal character is blocked. Any help is appreciated!
If IsNumeric(e.KeyChar) = True Then
e.Handled = False
ElseIf e.KeyChar = Chr(46) Then
e.Handled = False
ElseIf e.KeyChar = vbBack Then
e.Handled = False
Else
e.Handled = True
End If
Windows Forms20
|