Text Box Enter - vb6

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • parkho
    New Member
    • Feb 2008
    • 6

    Text Box Enter - vb6

    Hi, I have a text box in a form which I want to work with Enter key meaning when we type a text and hit the Enter key it works.
    thanks
  • xLin
    New Member
    • Jan 2008
    • 3

    #2
    Well, under the Textbox Key_Press, add this.
    Code:
    If KeyAscii = 13 Then
    KeyAscii = 0 'Prevents the beep
    'Actions here
    End If
    Done.

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      One technique I've used in the past is to hide a command button somewhere (or leave it visible, so the mouse can also be used) and set its .Default property to True. That way, as far as I can recall, it should trigger when Enter is pressed. However, I seem to also remember that it still beeps, so you may need to use xLin's code to suppress that.

      Note, it might be better to use the form's KeyPress or KeyDown event, rather than the textbox's, but to do that you need to set the form's KeyPreview property to True.

      (Note: by "hide" I mean to obscure it behind something or off the edge of the form. If you actually set it to not visible, I'm pretty sure it won't respond to any user events.)

      Comment

      Working...