I have it so i can recognise when the Enter key is pressed inside a text box, but how do I stop the annoying beep?
Printable View
I have it so i can recognise when the Enter key is pressed inside a text box, but how do I stop the annoying beep?
for me it's working ,
VB Code:
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress If (Asc(e.KeyChar())) = 13 Then e.Handled = True End If End Sub
Yeah, this works for me too without the beep. Just a slightly different way of doing it compared to the other one.
Code:Private Sub txtDataFormat_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtDataFormat.KeyPress
'Ceck if enter was pressed
If e.KeyChar = Microsoft.VisualBasic.ChrW(13) Then
e.Handled = True
'Is this textbox active or not?
If (Me.txtDisplay.Enabled = True) Then
'Ok go here then
Me.txtDisplay.Focus()
Else
'No it's not so move to the command button instead
Me.cmdClose.Focus()
End If
End If
End Sub
Your way is good if you are moving focus to other control otherwise it's as same as mine:D
Nicky is your textbox set to multilines:rolleyes: ?If so , then you would be in trouble I guess