Results 1 to 11 of 11

Thread: Computer wont stop "BEEP"

  1. #1

    Thread Starter
    Hyperactive Member onerrorgoto's Avatar
    Join Date
    Aug 1999
    Location
    Sweden
    Posts
    330

    Post

    I have a bunch of textboxes and lets the user press enter to jump to the next textbox in the form.
    But when he hits enter the computer "beeps" as it jumps to the next textbox.

    This is the code
    Private Sub txtSendTo_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyReturn Then
    frmNetSend.txtMessage.SetFocus
    End If
    End Sub

    This is the question
    Why does the computer beep and how can I force it not to?

    ------------------
    ******
    on error goto bed ;0)
    [email protected]
    *******


  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    Yep, you do, but there's a work around:

    Code:
    Private Sub txtSendTo_KeyDown(KeyCode As Integer, Shift As Integer)
    
       If KeyCode = vbKeyReturn Then
          frmNetSend.txtMessage.SetFocus
          KeyCode = 0
       End If
    End Sub

    Regards,

    ------------------

    Serge

    Software Developer
    [email protected]
    [email protected]
    ICQ#: 51055819


  3. #3

    Thread Starter
    Hyperactive Member onerrorgoto's Avatar
    Join Date
    Aug 1999
    Location
    Sweden
    Posts
    330

    Post

    Thank you

    but why Keycode=0 ?

    And I'm sorry but it doesn't work on my machine. the computer beeps when it jumps to the next textbox
    ------------------
    ******
    on error goto bed ;0)
    [email protected]
    *******



    [This message has been edited by onerrorgoto (edited 11-16-1999).]

  4. #4
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    The problem is that Serge's solution needs to be in KeyPress and not in KeyDown like so:
    Code:
    Private Sub txtSendTo_KeyPress(KeyAscii As Integer)
    
        If KeyAscii = vbKeyReturn Then
            KeyAscii = 0
            txtmessage.SetFocus
        End If
    
    End Sub
    And the KeyCode = 0 is there to "eat" the keystroke if it's vbKeyReturn. It's a common way to force user to enter a certian (usually small) set of values.

    ------------------
    Marty

    [This message has been edited by MartinLiss (edited 11-16-1999).]

  5. #5

    Thread Starter
    Hyperactive Member onerrorgoto's Avatar
    Join Date
    Aug 1999
    Location
    Sweden
    Posts
    330

    Post

    Thank you very much

    ------------------
    ******
    on error goto bed ;0)
    [email protected]
    *******


  6. #6
    Member
    Join Date
    Jun 1999
    Posts
    44

    Post

    Won't stop beeping?

    KICK THE CRAZY THING!!!!!!!!!!

    Sorry I couldn't resist

    Lloyd

  7. #7
    Junior Member
    Join Date
    Jul 2000
    Posts
    25

    Thumbs up F&(*&#@ing beeping

    That's great to finally find a workaround for that infernal beeping!!


  8. #8
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    You might want to consider using SendKeys in the procedure to make it more general.
    Because you can then use the same code for all the textboxes and you don't have to change the code if you change the TabOrder of the controls.
    Code:
    Private Sub Text1_KeyPress(KeyAscii As Integer)
        If KeyAscii = vbKeyReturn Then
            SendKeys "{TAB}"
            KeyAscii = 0
        End If
    End Sub
    Best regards

  9. #9
    Hyperactive Member Steve Stunning's Avatar
    Join Date
    Jul 1999
    Location
    Fairfax, Virginia
    Posts
    314

    I would use the
    SendKeys "{TAB}" vs frmNetSend.txtMessage.SetFocus

    That way you can keep control of what is next with the tab setting instead of having to change your code in case you needed to move or add things later on.

    Steve Stunning

  10. #10
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Originally posted by Steve Stunning

    I would use the
    SendKeys "{TAB}" vs frmNetSend.txtMessage.SetFocus

    That way you can keep control of what is next with the tab setting instead of having to change your code in case you needed to move or add things later on.
    Yup, that is just what I said in my previous post.

  11. #11
    Hyperactive Member Steve Stunning's Avatar
    Join Date
    Jul 1999
    Location
    Fairfax, Virginia
    Posts
    314


    LOL Just siding with you.. Not trying to take credit.
    Steve Stunning

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