This isn't really gonna help, but it may give you an idea. From the Form's Keydown event, use KeyCodes to recognize what button was pushed...but the downside is that I can only get it to recognize one button at a time.
Sorry!
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
' U = 85
' Insert = 45
If KeyCode = 85 Then
Load frmWhatever
frmWhatever.Visible = True
End If
End Sub
What I would suggest is using control instead of insert. The keyascii variable will have the valus 21 when you hit ctr+U, 85 when you hit shift+u and 117 when you just hit u.
Insert + U really has no meaning. The only problem I think you may come in contact with is if something else has a keyascii value of 21 also. This may be a problem. I havent played around with it enough to see. So, you could use the KeyPress event in the way mentioned above and capture 21 as your value. I cant get insert to throw up the value 45 like mastersword is suggesting that it does.
Another thing that you could do id to set up a form scope variable to keep the previous character pressed and check to see if the previous one was insert (Given that you can get it to fire off the keypress, down or up event) and the current is u hten do you code. There should be a way to get this to work out for you.
I'd also advise against using Insert, however, if you must, then here's one possible solution: [tt]
Option Explicit
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If (KeyCode = 45 Or KeyCode = vbKeyU) And (GetAsyncKeyState(vbKeyU) And GetAsyncKeyState(vbKeyInsert)) = -32768 Then
MsgBox "Insert U pressed"
End If
End Sub
Private Sub Form_Load()
Me.KeyPreview = True
End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.