TextBox Events

JCel

Active member
Joined
Jun 15, 2009
Messages
30
Programming Experience
Beginner
Hi I have used TextBox to get password(already few passwords are stored in my database)…. So now if the password matches the one in DB then it has to enter to the next form using Enter key(in keyboard) …

I tried using keypress and keydown events but it is entering to the next form as soon as any key is pressed from the keyboard

Eg. Password in DB is “admin” and now I entered “admin3” in textbox it enters to the next form as soon as I type 3 in “admin3” but my actual password is “admin”.

Now, My question is which event should we use for the above action?
 
VB.NET:
	Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
		If e.KeyCode = Keys.Enter OrElse e.KeyCode = Keys.Return Then
			'Check if password matches
		Else
			e.Handled = True
		End If
	End Sub
 
Back
Top