Beep whenever i press ENTER on a textbox - Programmers Heaven

Howdy, Stranger!

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

Categories

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.