Cursor Move Next object by Pressing Enter

This code shows how to cursor move to the next object by pressing Enter or Return key by Keyboard.

Call subprocedure EnterNextTab under Object Keypress procedure.


Private Sub txtEmpNo_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtEmpNo.KeyPress
EnterNextTab(Me.txtEmpNo, e)
End Sub

This sub prcedure ensure to move the cursor to the next Object

Public Sub EnterNextTab(ByVal Sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
Dim KeyAscii As Short = Asc(e.KeyChar)
If KeyAscii = 13 Then
System.Windows.Forms.SendKeys.Send("{TAB}")
End If
e.KeyChar = Chr(KeyAscii)
If KeyAscii = 0 Then
e.Handled = True
End If
End Sub


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: