So I'm trying to make a program which detects when I key is pressed down and assigns the value of said to a variable and then outputs it in a message box, however I cannot do this because of the follow error:
Method 'Main_KeyDown' cannot handle event 'KeyDown' because they do not have a compatible signature.
I am not sure why this is or why this is happening, it does not throw an error when I use the KeyPress event, but does also happen why I try to use KeyUp - however for this program I need it to work with KeyDown.
Here is the code in question:
Private Sub Main_KeyDown(sender As Object, e As KeyPressEventArgs) Handles MyBase.KeyDown
_keyDown = e.KeyChar
MsgBox(_keyDown)
End Sub
I am very lost for ideas here, never come across this error before, i've tried Googling and looking at other Overflow posts but none of them helped.
The method is not valid for a KeyDown event because the signature of that event (and KeyUp also) is different from the signature of KeyPress
Use instead
Look here for the differences between KeyDown, KeyPress and KeyUp