473,387 Members | 1,724 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,387 software developers and data experts.

handle ctrl+enter

hello,

i have a userform in a vba macro which contains three text boxes. sometimes i want to fill in only the first one, and other times one or two of the other as well. when i today want to leave a box empty, i have to press [tab] one or several times to reach the "submit" command button.

is there a way that i could trigger the btnSubmit_Click() event by pressing [Ctrl]+[Enter]? how?
Sep 12 '07 #1
4 2503
... is there a way that i could trigger the btnSubmit_Click() event by pressing [Ctrl]+[Enter]? how?

Hi,

Check the below code, I think that will answer your question

Expand|Select|Wrap|Line Numbers
  1. Private Sub  btnSubmit_Click() 
  2. MsgBox "Submitted"
  3. End Sub
  4.  
  5. Private Sub Text1_KeyPress(KeyAscii As Integer)
  6. If KeyAscii = 10 Then
  7.   btnSubmit_Click
  8. End If
  9. End Sub
Reply me...
Sep 12 '07 #2
hariharanmca
1,977 1GB
... is there a way that i could trigger the btnSubmit_Click() event by pressing [Ctrl]+[Enter]? how?
I think the below link will help you

KeyAscii
Sep 12 '07 #3
Hi,

Check the below code, I think that will answer your question

Expand|Select|Wrap|Line Numbers
  1. Private Sub  btnSubmit_Click() 
  2. MsgBox "Submitted"
  3. End Sub
  4.  
  5. Private Sub Text1_KeyPress(KeyAscii As Integer)
  6. If KeyAscii = 10 Then
  7.   btnSubmit_Click
  8. End If
  9. End Sub
Reply me...
thank you! this worked excellently!
Sep 14 '07 #4
Hi,

Check the below code, I think that will answer your question

Expand|Select|Wrap|Line Numbers
  1. Private Sub  btnSubmit_Click() 
  2. MsgBox "Submitted"
  3. End Sub
  4.  
  5. Private Sub Text1_KeyPress(KeyAscii As Integer)
  6. If KeyAscii = 10 Then
  7.   btnSubmit_Click
  8. End If
  9. End Sub
Reply me...
this worked, but now i'm building an application with a lot of controls in several forms. is there a way i could get the same results as if i coded a similar procedure for each control, but by just having one sub? that is, a sub that handles keypress events regardless of which control sends the event.
Sep 19 '07 #5

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

Similar topics

10
by: Deano | last post by:
I think that just about sums it up. Is there a fix/workaround for this?It's quite annoying behaviour and not user-friendly.thanksMartin
0
by: Coder | last post by:
hi, i am using a c# windows application. i want to handle some keypress events like ctrl+A, shift+enter, etc.. is it easy to handle only one keypress; as KeyPressEventArgs e;... e.KeyPress. ...
3
by: Coder | last post by:
hi, there is still no answer, i wonder if there is a way to handle the multiple key-press event on a C# windows form, like "Ctrl+Enter"
0
by: Narshe | last post by:
I'm using the excel object from office web components in an asp.net webpage. I have 2 major issues. When a user hits enter on a cell, it moves cells. That's fine, 'cause that's how excel...
3
by: yuelinniao | last post by:
hi, I have got a simple way to make "textarea" support "auto-submit" when pressing Ctrl+Enter, and tested under both IE and Firefox. The common old method is like this: <form name=form2>...
2
by: sravan_reddy001 | last post by:
i had designed a win app(an address book) when the user wants to enter the contact he will type in all the details and "HE SHOULD CLICK ON THE ADDENTRY BUTTON PROVIDED" i want to simplify this...
1
by: ahmadnadeem | last post by:
Sir i want that when i press four times the enter key the cursor should come to the new line withen rich textbox in c# language.
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...

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.