Moving a control object using Keycode in VB6

This tutorial lets you control the control object to move using the Visual Basic Keycodes with the Keydown Event

Step 1:
Open your VB Application.


Step 2:
Select Standard EXE and Click Open.

Step 3:
Click the form, find the Caption and change it, Set the BackColor Property in any color you want.


Step 4:
Select the Shape tool Click and Drag to the form then change the Shape to 3 – Circle and set the FillColor to Red, FillStyle = 0 – Solid.

Step 5:
Double click the form then go to the Event Procedure and select the Keydown Event.


Step 6:
In this case we are using the Select Case Statement to control every keystroke of A,W,S,D.

There you have it!


You can change the keycode into arrow keys if you want

vbKeyW to vbKeyUp
vbKeyA to vbKeyLeft
vbKeyS to vbKeyDown
vbKeyD to vbKeyRight

Good Luck! Happy coding J
Moving a control object using Keycode in VB6 Moving a control object using Keycode in VB6 Reviewed by code-dev on 6:41 PM Rating: 5

No comments:

Powered by Blogger.