I have visual basic 2005 express edition and don't know how to execute the code of a button by pressing the enter key.
Thanks
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Scott LyslePosted Nov 8, 2006, 11:02 PM
Set the form's KeyPreview property to true, it is set to false by default. Then handle the form's key press event:
Private
Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown If e.KeyCode() = Keys.Enter ThenMessageBox.Show(TextBox1.Text)
End If End Sub