Results 1 to 4 of 4

Thread: Need help trapping Enter key

  1. #1

    Thread Starter
    Registered User
    Join Date
    May 2013
    Posts
    1

    Need help trapping Enter key

    Attached is the code(some of it were not mine) and i would like to extend it...
    but for some reason, im having problems trapping the "Enter" key,
    any help would be very much appreciated...thanks.
    Attached Files Attached Files

  2. #2
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: Need help trapping Enter key

    It seems that the CommandButton "consumes" the Enter key, preventing the Form from ever being notified of the keypress. This happens even when subclassing either the Form or the CommandButton (watching for BN_CLICKED or WM_CHAR/WM_KEYDOWN messages). I've noticed that Microsoft's Calculator doesn't allow setting the focus to any button, thus enabling the Enter key to work correctly. Perhaps you may want to emulate that behavior. Another possible workaround is to use a UserControl button in lieu of the CommandButton.
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  3. #3
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Need help trapping Enter key

    Been a long time since I did VB6 - but don't you have to enable ENTER key trapping on the properties of the FORM itself?

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  4. #4
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Need help trapping Enter key

    What are you trying to do with this code?

    vb Code:
    1. Dim intIndex    As Integer
    2.    
    3.     If KeyAscii = vbKeyReturn Then
    4.         intIndex = 23
    5.         cmdCalc(intIndex).SetFocus
    6.         cmdCalc_Click intIndex
    7.     End If

    press the "Enter" button when the "txt_Paper" has focus?
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

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