HandsOn Writing the Form KeyUp Event Procedure

1. Open the Suppliers form in Design view.

2. Click the Properties button and, in the Form properties sheet, click the Event tab.

3. Set the Key Preview property to Yes.

4. Save the Suppliers form.

5. In the Code window there are a couple of event procedures already written for this form. Enter the following Form_KeyUp event procedure below the last procedure code.

Private Sub Form_KeyUp(KeyCode As Integer, _ Shift As Integer) Debug.Print "You released " & _

KeyCode & Space(1) & Chr(KeyCode)

End Sub

6. To test the above event procedure, open the Suppliers form in Form view. Press the Down Arrow key three times to move to the Address field. Press the End key to move to the Home Page field. Type www.exotliq.com. Use the Backspace key to delete what you have just typed.

7. Switch to the Visual Basic Editor window and activate the Immediate window. You should see a listing of the keys that were released while performing step 6 above.

8. Close the Suppliers form.

0 0

Post a comment