How to determin if return was pressed

  • Thread starter Thread starter Alex
  • Start date Start date
A

Alex

Dear colleagues

How can I determin if "return button was pressed" in a textbox? I am trying
to di this with this methode:
Private Sub txbInput_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles txbInput.KeyDown
GetMembers()

End Sub



Thanks ALex
 
Hi,
Try this :

Private Sub txbInput_KeyPress(ByVal sender As Object, ByVal e As
KeyPressEventArgs)
if (e.KeyChar = 13) Then '13 = Ascii code for return
'your code
End If
End Sub
 
Thanks a lot !! Alex
Pierre said:
Hi,
Try this :

Private Sub txbInput_KeyPress(ByVal sender As Object, ByVal e As
KeyPressEventArgs)
if (e.KeyChar = 13) Then '13 = Ascii code for return
'your code
End If
End Sub
 
you could also use the keydown event

Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If e.KeyCode = Keys.Enter Then
'do stuff
End If
End Sub

grtz Peter
 
Try this

If Asc(e.KeyChar) = 13 Then
' Return was pressed
End If

Gary
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top