I'm trying to treat the Enter key in a textbox as the Tab key. Thanks to a
post which Google came up with I have coded a technique using GetNextControl
(see below). But it doesn't work. It seems to not work because the If
statement checking for the Enter key fails. So I added the two MsgBox
statements to display the value of the entered key and the Enter key. Both
display as 13 when I enter the Enter key and yet the code fails - I never
see the message box saying "it's an Enter key" and no tabbing action occurs.
I'm sure it's some really dumb mistake but I do not see it. Any assistance
will be much appreciated.
Thanks, Bob
Private Sub tbxYear_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) _
Handles tbxYear.KeyPress
MsgBox("e.KeyChar is " & Decimal.op_Implicit(e.KeyChar).ToString)
MsgBox("Keys.Enter is " & Decimal.op_Implicit(Keys.Enter).ToString)
If e.KeyChar.Equals(Keys.Enter) Then 'if Enter key then tab forward
MsgBox("it's an Enter key")
tbxYear.GetNextControl(tbxYear, True)
e.Handled = True
Return
End If