VB.NET School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 300,430 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,491 people online right now. Registration is fast and FREE... Join Now!




ENTER KEY

 

ENTER KEY

mary21clare

2 Jul, 2009 - 10:34 AM
Post #1

New D.I.C Head
*

Joined: 24 Jun, 2009
Posts: 10

I have a login form that I made. The user enters a username in textbox1 and then enters a password in textbox2. The user then hits the submit button (button2) and from there it works beautifully. The problem is, I would also like the user to be able to hit the "enter" key after they fill out the password textbox (textbox2) and have it be like they pressed the submit button. When the user hits enter right now, the form hides... I don't know what to do! please help!

User is offlineProfile CardPM
+Quote Post


zippp

RE: ENTER KEY

2 Jul, 2009 - 10:52 AM
Post #2

New D.I.C Head
*

Joined: 22 Jun, 2009
Posts: 39



Thanked: 4 times
My Contributions
use the keypress event

CODE

Private Sub textbox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles textbox2.KeyPress
If Asc(e.KeyChar) = Keys.Enter Then

'here you put your code...the code from the submit button and the code for hidding textbox1 or textbox2

End If
End Sub


i hope this will help you
User is offlineProfile CardPM
+Quote Post

mary21clare

RE: ENTER KEY

2 Jul, 2009 - 11:30 AM
Post #3

New D.I.C Head
*

Joined: 24 Jun, 2009
Posts: 10

QUOTE(zippp @ 2 Jul, 2009 - 10:52 AM) *

use the keypress event

CODE

Private Sub textbox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles textbox2.KeyPress
If Asc(e.KeyChar) = Keys.Enter Then

'here you put your code...the code from the submit button and the code for hidding textbox1 or textbox2

End If
End Sub


i hope this will help you



I guess what I don't understand is what code you put in there. How can i link it to button1 being clicked?
User is offlineProfile CardPM
+Quote Post

PsychoCoder

RE: ENTER KEY

2 Jul, 2009 - 01:38 PM
Post #4

Dyslexics Untie!
Group Icon

Joined: 26 Jul, 2007
Posts: 14,714



Thanked: 501 times
Dream Kudos: 11450
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

My Contributions
A much easier way (required no code) is to set the Form's AcceptButton Property to your submit button (If this is a Windows Application)
User is offlineProfile CardPM
+Quote Post

zippp

RE: ENTER KEY

2 Jul, 2009 - 09:31 PM
Post #5

New D.I.C Head
*

Joined: 22 Jun, 2009
Posts: 39



Thanked: 4 times
My Contributions
you put there the submit button's code and when you hit enter the action will be the same like button2.

actualy you have to choice. you type in the user and pass and u click the submit button or just hit the enter key.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 12:33AM

Live VB.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month