Enter key plays windows beep

Eleventeen

Active member
Joined
Jan 3, 2003
Messages
39
Location
Canada
I have many text boxes that when you press the enter key it sends the focus to the next control but windows plays the beep sound. Each time for each box. All I am using is the keypress event.

Any help is much appreciated

Thanks!
 
One solution should be to create your own textBox and do something like:

Code:
Public Class myTextBox
  Inherits TextBox

  Protected Overloads Overrides Sub OnKeyPress(ByVal e As KeyPressEventArgs)
    If Asc(e.KeyChar) = Keys.Enter Then
      e.Handled = True
    End If

    MyBase.OnKeyPress(e)
  End Sub
End Class

So if the user press enter, you say that the key press has already been handled and so it wont beep
 
Code:
    Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        If Asc(e.KeyChar) = Keys.Return Then
            TextBox2.Text = TextBox1.Text
            e.Handled = True
        End If
    End Sub
i noticed , you were putting Keys.Enter , its keys.return you want
the above code will sort you out:)
 
Back
Top