-
VB .net question
I am writing my first VB .net program and want to know, how I can recognise when someone presses the return key when a specific text box has focus. As I want to execute some code when someone has entered some text in this text box and hit the return key.
Thanx in advance,
TTAYO
-
Code:
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If e.KeyCode = Keys.Return Then
MsgBox("detects that the return/enter has been pressed")
End If
End Sub
pass in the right data, throw in a simple if statement, then execute whatever code you want.
-
Thanx for that!
I know that it was a simple piece of code, as I could do it with VB6. But I haven't programmed in VB for about 3 years and I need to catch up and refresh my memory.
L8R,
TTAYO