I want to make a public sub in my module to to store a repeating procedure. Specifically key press events.
Private Sub txtPass_KeyPress(sender As Object, e As KeyPressEventArgs) _
Handles txtPass.KeyPress
FunctionKeys(Me, sender, e)
End Sub
Public Sub FunctionKeys(form as object, sender as object, _
e as KeyPressEventArgs)
With form
If e.KeyChar = ChrW(Keys.Enter) Then .btnOk_Click(sender, e)
If e.KeyChar = ChrW(Keys.Escape) Then .btnClose_Click(sender, e)
end with
End sub
I guess it would look something like this. Unfortunately, this tells me it can't find a public sub for formname.btnok_click etc. I want to know if there's a way around this. Looking around the net I found I can use the AcceptButton and CancelButton property. But only if i actually have a button to press. My MDI does not have buttons. Just menu. Also, I'm aware I can use formname.close() for the Keys.Escape. But I'd still have a problem with the OK button.