• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 312
  • Last Modified:

VB 2005: How to Make Pressing "Enter" key to execute all commands under btnEnter_click?

Dear Experts:

Hi!

Here is what I would like to do:

1. In the btnEnter_click sub procedure, I have several commands.
   When "Enter" button is pressed, all the commands are executed properly.
2. Obviously it is much easier to press "Enter" key than to locate the "Enter" button on a small form and to click it.

3.  I have a code which I would like to use to use "Enter" key in the keyboard.

Private Sub txtUSDollar_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtCelcius.KeyUp
        If e.KeyCode = Keys.Enter Then
           
      '  Body'



        End If
    End Sub


My question is: Should I copy all the codes in the btnEnter_click and paste it in the area marked
'Body' above?

May I consider btnEnter_click a sub procedure and make it as the follows:

Private Sub txtUSDollar_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtCelcius.KeyUp
        If e.KeyCode = Keys.Enter Then
           
       btnEnter_Click ()



        End If

I tried the second and it did not work.

I am a novice but working hard to learn.

Thanks!
   
0
duta
Asked:
duta
1 Solution
 
BinuthCommented:
set your form's "AcceptButton" property to "btnEnter"
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now