Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Beep whenever i press ENTER on a textbox

dalvarezmtzdalvarezmtz Posts: 1Member
Dudes!! help please!!
i have 2 textboxes...the first one gets focused to the second one.. and the second one fires a function... but everytime i get the ENTER key pressed sounds an annoying beep...

how can i get rid of it!!??

here is my code folks... hope someone knows...<<<
Private Sub txtfrecval_Keydown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtfrecval.KeyDown
If e.KeyCode = Keys.Enter Then
Me.txtvalfrec.Focus()
e.Handled = True
End If
End Sub
Private Sub txtvalfrec_Keydown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtvalfrec.KeyDown
If e.KeyCode = Keys.Enter Then
Me.frecuencias()
txtfrecval.Clear()
txtvalfrec.Clear()
txtfrecval.Focus()
e.Handled = True
End If

Comments

  • BaldusariusBaldusarius Posts: 162Member
    The easiest fix is to handle the KeyPress event instead of KeyDown.

    : Dudes!! help please!!
    : i have 2 textboxes...the first one gets focused to the second one.. and the second one fires a function... but everytime i get the ENTER key pressed sounds an annoying beep...
    :
    : how can i get rid of it!!??
    :
    : here is my code folks... hope someone knows...<<<
    : Private Sub txtfrecval_Keydown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtfrecval.KeyDown
    : If e.KeyCode = Keys.Enter Then
    : Me.txtvalfrec.Focus()
    : e.Handled = True
    : End If
    : End Sub
    : Private Sub txtvalfrec_Keydown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtvalfrec.KeyDown
    : If e.KeyCode = Keys.Enter Then
    : Me.frecuencias()
    : txtfrecval.Clear()
    : txtvalfrec.Clear()
    : txtfrecval.Focus()
    : e.Handled = True
    : End If
    :

  • kainsworthkainsworth Posts: 200Member
    : The easiest fix is to handle the KeyPress event instead of KeyDown.
    :


    And don't forget to change from KeyCode to KeyChar when you do :-)

    Private Sub QuickLocateTextBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles QuickLocateTextBox.KeyPress
    If e.KeyChar = Chr(13) Then
    e.Handled = True
    End If
    End Sub

    Ged
Sign In or Register to comment.