|
-
Nov 6th, 2000, 01:30 PM
#1
Thread Starter
Member
Hello,
Here is my problem.
When the user is on my form and if he / she hits ctrl + enter at the same time, I want certain text from a text box to move to another text box.
So im thinking I would do this is a form1_keypressevent??
enter key is chr(13) but what is the ctrl key?
Any help.
Thanks.
-
Nov 6th, 2000, 01:54 PM
#2
Fanatic Member
Instead of using the KeyPress event, use the KeyDown event (or KeyUp, but try down first). That way, you can check Shift to see if shift, control, or alt was pressed when the event was fired.
I'm baaaack...
VB5 Professional Edition, VC++ 6
Using a 1 gHz Thunderbird, 256 mb RAM, 40 gb HD system with Win98se
I feel special because I finally figured out how to loop midis: Post link
I'm a fanatic too 
-
Nov 6th, 2000, 01:57 PM
#3
Hyperactive Member
As Kaverin said. Shift will return 2 if ctrl was pressed.
-
Nov 6th, 2000, 01:57 PM
#4
Lively Member
you have to trap keycode
You have to write the code either in keyDown or keyUp not in keyascii.Since keyascii cannot trap the ctrl key whereas keycode traps it.
So the keycode for ctrl key is 17.
When you want to trap the code of function keys and the keys like ctrl,alt etc then you have to use keycode.
Hope iam clear
regards
-
Nov 6th, 2000, 02:05 PM
#5
Thread Starter
Member
I understand it now anilgoje. Thanks for all of your help people.
-
Nov 6th, 2000, 02:12 PM
#6
Frenzied Member
This will work...
This code will capture the "Ctrl + Enter" keys and display a message box when they are pressed.
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If (KeyCode = vbKeyReturn) And (Shift = vbCtrlMask) Then
MsgBox "You pressed Ctrl + Enter"
End If
End Sub
[Edited by seaweed on 11-06-2000 at 02:20 PM]
-
Nov 6th, 2000, 04:47 PM
#7
Thread Starter
Member
hmmm
I have tried both ways and It is still not working.
First way.
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
if chr(13) and chr(17) then
msgbox"working?"
end if
End Sub
'// second way
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If (KeyCode = vbKeyReturn) And (Shift = vbCtrlMask) Then
MsgBox "You pressed Ctrl + Enter"
End If
End Sub
Any ideas?
-
Nov 6th, 2000, 05:01 PM
#8
Frenzied Member
um....
I think its not working because the first way has
Code:
MsgBox"working"
'and not
MsgBox "working"
If not then i dont know
retired member. Thanks for everything 
-
Nov 6th, 2000, 05:08 PM
#9
Thread Starter
Member
No that isnt the problem. I am only putting msgbox's up there so I can see if it works before I put in the rest of my code. 
I have also tried keyup as well as keydown events.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|