Jaruzel.com

Disable Beep in a Textbox


(vs2003)
'
'This will disable that 'Beep' when you press the 'Enter' key in a Textbox control. You want to
'put this code in the TextBox_KeyPress event of your Textbox.
'
'You can use the 'Carriage Return Character' constant: 'vbCr' as the KeyChar to check or you can
'simply use: Chr(13). The end result is the same.
'
If e.KeyChar = Chr(13) Then

e.Handled = True

End If
'
'or using the constant as the KeyChar below:
'
If e.KeyChar = vbCr Then

e.Handled = True

End If

(vs2005)
If e.KeyCode = Keys.Enter Then

e.SuppressKeyPress = True

e.Handled = True
End If