E
eBob.com
I am trying to make the Enter key, when entered into a textbox, function
like the tab key. An earlier problem was resolved by Branco and Armin
(thanks again gentlemen). The problem which baffles me now is that
tbxYear.GetNextControl(tbxYear, True) [where tbxYear is a Textbox] results
in "Object reference not set to an instance of an object". Both of the
following statements raise this exception:
MsgBox(" tbxYear.GetNextControl(tbxYear, True).ToString returns: " & _
tbxYear.GetNextControl(tbxYear, True).ToString)
tbxYear.GetNextControl(tbxYear, True).Focus()
Here's the code in context ...
Private Sub tbxYear_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) _
Handles tbxYear.KeyPress
If e.KeyChar = ChrW(Keys.Enter) Then 'if Enter key then tab forward
'MsgBox("it's an Enter key")
MsgBox(" tbxYear.GetNextControl(tbxYear, True).ToString returns: " & _
tbxYear.GetNextControl(tbxYear, True).ToString)
tbxYear.GetNextControl(tbxYear, True).Focus()
e.Handled = True
Exit Sub
End If
I'll appreciate any advice/help you can offer. (And I am sorry for all of
the wasted space here. OE went into double space mode when I cut and pasted
the code from VS and I don't seem to be able to change that. Another
problem to research. Sigh!)
Bob
like the tab key. An earlier problem was resolved by Branco and Armin
(thanks again gentlemen). The problem which baffles me now is that
tbxYear.GetNextControl(tbxYear, True) [where tbxYear is a Textbox] results
in "Object reference not set to an instance of an object". Both of the
following statements raise this exception:
MsgBox(" tbxYear.GetNextControl(tbxYear, True).ToString returns: " & _
tbxYear.GetNextControl(tbxYear, True).ToString)
tbxYear.GetNextControl(tbxYear, True).Focus()
Here's the code in context ...
Private Sub tbxYear_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) _
Handles tbxYear.KeyPress
If e.KeyChar = ChrW(Keys.Enter) Then 'if Enter key then tab forward
'MsgBox("it's an Enter key")
MsgBox(" tbxYear.GetNextControl(tbxYear, True).ToString returns: " & _
tbxYear.GetNextControl(tbxYear, True).ToString)
tbxYear.GetNextControl(tbxYear, True).Focus()
e.Handled = True
Exit Sub
End If
I'll appreciate any advice/help you can offer. (And I am sorry for all of
the wasted space here. OE went into double space mode when I cut and pasted
the code from VS and I don't seem to be able to change that. Another
problem to research. Sigh!)
Bob