Results 1 to 6 of 6

Thread: When enter is not Enter

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2010
    Posts
    402

    When enter is not Enter

    I currently have a form with a text box on it. within the form I have a trigger on Enter being pressed. An example is :-

    Code:
    Private Sub TextBox1_Enter()
    MsgBox ("enter")
    End Sub

    however when enter is pressed, the procedure is not triggered ?

  2. #2
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,106

    Re: When enter is not Enter

    You seem to be confused. That Sub has nothing to do with the Enter key being pressed. It will execute when the TextBox is "entered", like when the cursor is moved to that textbox.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2010
    Posts
    402

    Re: When enter is not Enter

    That's what it generated when i selected the Enter function.

    How do I detect when the enter is pressed in a text box ?

  4. #4

  5. #5
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,106

    Re: When enter is not Enter

    Quote Originally Posted by Signalman View Post
    That's what it generated when i selected the Enter function.

    How do I detect when the enter is pressed in a text box ?
    Right, and the Enter function has nothing to do with detecting the pressing of the Enter key.

    One way is to check for a KeyCode value of 13 inside of the KeyDown event.

  6. #6
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,382

    Re: When enter is not Enter

    Quote Originally Posted by OptionBase1 View Post
    Right, and the Enter function has nothing to do with detecting the pressing of the Enter key.

    One way is to check for a KeyCode value of 13 inside of the KeyDown event.
    I'd rather use the KeyUp-Event, since there the entered KeyCode is already part of the content of the Textbox
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

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