Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable beep on enter keypress in textboxes 2

Status
Not open for further replies.

ribsa3

Programmer
Jun 17, 2003
56
Hi,

I was wondering how I can disable the beep when enter is pressed within a textbox. I am currently handling the enter-event with the following snippet of code and would do well with squelching the bell in there:

Private Sub txtCustNo_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtCustNo.KeyPress

If (e.KeyChar = Microsoft.VisualBasic.ChrW(13)) Then

' Have fun here

End if

End Sub





--------------------------------------------------------------------
Do what you wish, as long as it harms no one. That includes yourself.
 
If (e.KeyChar = Microsoft.VisualBasic.ChrW(13)) Then
' Turn beep off
e.KeyChar = 0
End if
 
Thanks for the suggestion - I actually tried the same thing, but e.KeyChar is read-only so I can't assign a new value to it
:/

-B



--------------------------------------------------------------------
Do what you wish, as long as it harms no one. That includes yourself.
 
I would go for this

Code:
if Asc(e.KeyChar)= 13 then
   System.Windows.Forms.SendKeys.Send("{TAB}")
   e.Handled = True
endif

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
Yay :)



--------------------------------------------------------------------
Do what you wish, as long as it harms no one. That includes yourself.
 
Heeeelp!!!

There is a beep whenever i press enter at a textbox..
how can i get rid of it...

Here is my code.. hope anyone knows..

thanks in advance guys....

Private Sub txtfrecval_Keydown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtfrecval.KeyDown
If e.KeyCode = Keys.Enter Then
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
End Sub
 
e.handled = true only works in the keypress event so transfer your code to there

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top