Problem : How do I trap on Ctrl-C, Ctrl-V and Ctrl-X using the KeyPress Event in VB.NET
I have done this in VB6 but not sure how to do it in VB.NET. Here is my VB6 Code:
————start VB6 code—————
Select Case KeyAscii
Case 3 ‘Ctrl-C Copy
‘Do something when Ctrl-C encountered
KeyAscii = 0
Case 22 ‘Ctrl-V Paste
‘Do something when Ctrl-V encountered
KeyAscii = 0
Case 24 ‘Ctrl-X Cut
‘Do something when Ctrl-X encountered
KeyAscii = 0
End Select
————end VB6 code—————
In VB.NET I have the following but it is wrong because ‘e.keychar’ returns a ‘String’ not an Iteger:
————start VB.NET code———————-
Select Case e.KeyChar
Case 3 ‘Ctrl-C Copy
‘Do something when Ctrl-C encountered
e.KeyChar = 0
Case 22 ‘Ctrl-V Paste
‘Do something when Ctrl-C encountered
e.KeyChar = 0
Case 24 ‘Ctrl-X Cut
‘Do something when Ctrl-C encountered
e.KeyChar = 0
End Select
————end VB.NET Code———————-
How do I use e.KeyChar to produce a proper ‘Case’ statement?
I know this is probably pretty simple but at the moment it eludes me.
Thanks in advance for any help.
Solution : How do I trap on Ctrl-C, Ctrl-V and Ctrl-X using the KeyPress Event in VB.NET
If e.KeyChar = Convert.ToChar(3) Then
msgbox “control C was pressed”
End If
something like this???