Henry Gathigira Henry Gathigira - 1 year ago 43
Vb.net Question

How to Set Enter is ok on Textbox in vb.net

I have a password textbox (Tbx1) and a Login button (Btn1). What code will i put where so that when the user
inputs password and presses enter, Btn1 clickevents will be exucuted?


on Form Misc Properties set the accept button to be Btn1. Equally, you can set a cancel button too to be executed whenever the user presses Esc button.

Code version (through the constructor):

Public Sub New()

    ' This call is required by the designer.

    ' Add any initialization after the InitializeComponent() call.
    Me.AcceptButton = Btn1
End Sub