In VB.net, how can I use the enter key on the keyboard to execute commands?

Andy

New member
I have a windows form and it contains 2 text box. Of which, 1 of them is for the username and the other is a password field. I also have a login button which has the execution codes for access granted like...

messagebox.show("Access granted!", "Welcome")

My question is how can I use the enter key on the keyboard and execute the following code and where can I enter this particular code? In this page_load or something?

if txtUsername.text = "myUser" and txtPassword.text = "1" then
messagebox.show("Access granted!", "Welcome")
else
messagebox.show("Access denied!", "Exit")
end if
 
Back
Top