Lesson5 (12/18)

Implementing Key press events

We don't want to change the KeyPress Event.We want that the code the user will insert to the KeyPress Event (Image 11) will be launched as usual, without any changes.

So we will enter the following lines to our form:
Private Sub Command1_KeyPress(KeyAscii As Integer)
RaiseEvent KeyPress(KeyAscii)
End Sub

Code Explanation: when the user press on the Command1 Button, simply launch the Control (MyControl) KeyPress event. The 'RaiseEvent' function launch an event. It launch the event with the KeyAscii parameter that has been received from the Command1 KeyPress event.