Results 1 to 5 of 5

Thread: Enter button to submit command

  1. #1

    Thread Starter
    Fanatic Member LITHIA's Avatar
    Join Date
    Dec 2002
    Location
    UK, England
    Posts
    575

    Enter button to submit command

    I made a password field and when i type my password, i want to easily press my Enter button and it presses a command button for me on the form.

    How would i make it do this? When i press my Enter/Return button, a command button gets pressed

  2. #2
    Fanatic Member holly's Avatar
    Join Date
    Aug 2002
    Location
    Somewhere on earth
    Posts
    721
    what about

    VB Code:
    1. Private Sub txtinformation_KeyPress(KeyAscii As Integer)
    2.     If KeyAscii = vbKeyReturn Then
    3.         cmdenter_Click
    4.      End If
    5.    Exit Sub
    6. End Sub

    Thanks
    ** HOLLY **

  3. #3
    Fanatic Member Geespot's Avatar
    Join Date
    Oct 2001
    Location
    Birmingham, UK
    Posts
    577
    Or set the default property of a Command button to True. This will make the command button pressed when ever you press the Enter button.

    And you can do same with the ESC key by setting the Cancel property of a command button to true

  4. #4

    Thread Starter
    Fanatic Member LITHIA's Avatar
    Join Date
    Dec 2002
    Location
    UK, England
    Posts
    575
    ah cool thanks for the quick reply

    two methods, ill try both!

    Thanks, cya

  5. #5
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    Instead of keypress you can have the keydown event. It is almost the same thing. :

    VB Code:
    1. Private Sub txtinformation_KeyDown(KeyCode As Integer, Shift As Integer)
    2.     If KeyCode = vbKeyReturn Then
    3.         cmdenter_Click
    4.      End If
    5.    Exit Sub
    6. End Sub


    Has someone helped you? Then you can Rate their helpful post.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width