473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how to use a textbox and hit enter to make it click a button

18
so basically i have a textbox and i need to be able to hit the enter key and have it click a button

its for my web browser project im doing for a final and cant seem to figure it out

i have the textbox for the URL area and a go button.

thanks for your help in advance!
Jan 11 '10 #1
4 5432
Delerna
1,134 Expert 1GB
You don't really need to make it click the button.
The onclick event for the button calls a function that you attach to it when you create the button.

All you need to do is in the onkeydown event for the textbox is
check to see if the enter key was pressed
if yes then call the same function that the buttons onclick calls
Jan 11 '10 #2
vb5prgrmr
305 Expert 100+
Delerna, the onkeydown event is either vba or .net as I know it is not a VB6 event...
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2.  
  3. Private Sub Command1_Click()
  4. MsgBox "clicked"
  5. End Sub
  6.  
  7. Private Sub Text1_KeyPress(KeyAscii As Integer)
  8. If KeyAscii = vbKeyReturn Then Command1.Value = True
  9. End Sub
  10.  

Good Luck
Jan 12 '10 #3
Delerna
1,134 Expert 1GB
Delerna, the onkeydown event is either vba or .net as I know it is not a VB6 event
That is true in the syntactical sense. I was refering to the event that occurs when you press a key down or click a button, thats why there was no code. I guess I should have written "the click event" rather than "onclick event" and "the key down event" rather than "onkeydown event" so I concede your point. I suppose the way I wrote them reflects where I do most of my development these days.

Whatever the syntax however, the idea still remains the same
also
ControlName_KeyDown(...) is indeed a valid VB6 event
as is
ControlName_KeyUp(...)
Jan 12 '10 #4
negus
18
Ah i got it, it was in the Form options just had to set the accept button to my go button, but thank you for the help!
Jan 12 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Jose Egea | last post by:
Hello: I'm trying to execute a function when the user press Enter key in a TextBox. But something is happening in my form because after pressing a button, when I press the Enter key in the...
2
by: George Durzi | last post by:
I have a text box and a button, and I want the enter key to run the click event of the button. The textbox and button are inside a user control. I tried all sorts of stuff with the __EVENTTARGET...
0
by: Tony Hedge | last post by:
Hello, I can briefly explain without providing any code, it's a simple NET 1.1 web project. I have a web form with a textbox A and button A (in a table row), and textbox B and button B (in a...
11
by: Joe | last post by:
Hello All, I have an ASP.NET page with one Textbox (SearchTextBox) and one ImageButton (SearchButton) server controls. The user can type search text in SearchTextBox and click SearchButton and...
5
by: TS | last post by:
for some reason, it posts to the server, but no click events of any buttons on form fire. the button is the first one on the form. when the focus is inside the textbox, it doesnt' work. if i click...
14
by: teddysnips | last post by:
WINDOWS FORMS I've a form that has a textbox that allows the user to enter a string. On the LostFocus event, the textbox formats the string into a preferred format. However, if the user...
5
by: Stuart Shay | last post by:
Hello All I am working on ASP.NET 1.1 Custom Pager that allows a User to Enter a Number in a TextBox and go to the page selected. Since the OnClick Event does not work in ASP.NET 1.1 for a...
4
by: slinky | last post by:
I have a textbox that a user enters the current time (in this case at the end of a task, and it gets its value via a button's click event and getting its value from =Now() ). Is there a way to...
1
by: daonho | last post by:
I tried to use javascript to trigger up the button click function when user press enter key from the textbox. This function work fine with a single button click such has login page. However, if the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.