|
-
Dec 23rd, 2009, 08:26 PM
#1
Thread Starter
Lively Member
Shortcut Keys in Visual Basic
Hi, I was wondering about how to apply shortcut keys (like control+c and control+v) in visual basic
There was a thread on this I found but I tried all the codes and variations but nothing worked, like nothing would happen when I pressed the keys
could someone give me the code about how to activate a "control+t" and a "control+r" control? thanks
the farthest I got was:
private sub form3_key down...........handles form3.keydown
if e.keycodes = keys.control and e.keycodes = keys.t then
msgbox("hi")
end if
end sub
I that was the best looking code I got, but it didn't work
i also did
For Each item As Control In Me.Controls
AddHandler item.KeyDown, AddressOf Form3_KeyDown
Next
i noticed if I did code for just pressing the control key it worked but when I tried to use two keys it didnt'
-
Dec 23rd, 2009, 08:32 PM
#2
Re: Shortcut Keys in Visual Basic
Did you set the KeyPreview property of the form to true?
CodeBank contributions: Process Manager, Temp File Cleaner
 Originally Posted by SJWhiteley
"game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....
-
Dec 23rd, 2009, 09:44 PM
#3
Hyperactive Member
Re: Shortcut Keys in Visual Basic
e.keydata should give you the codes you're looking for. Try this and see the different results:
Code:
Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
lblCode.Text = e.KeyCode
lblData.Text = e.KeyData
lblValue.Text = e.KeyValue
End Sub
e.keydata should reflect the ctrl+key combination.
Last edited by dkahn; Dec 23rd, 2009 at 09:52 PM.
-
Dec 23rd, 2009, 10:22 PM
#4
Fanatic Member
Re: Shortcut Keys in Visual Basic
You can use Andalso for that :
Code:
Private Sub TextBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp
If e.Control = True AndAlso e.KeyCode = Keys.D0 Then
MsgBox("manhit")
End If
End Sub
Tags for this Thread
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
|