Clicking Buttons to Perform Action
The easiest way to allow the user to interact with an application is to provide a button to click. You can use the command button control provided, or you can create your own "button" using an ICON control containing a graphic.
Using Command Buttons
Most GUI applications have command buttons that allow the user to simply click them to perform actions. When the user chooses the button, it not only carries out the appropriate action, it also looks as if it's being pushed in and released. When the user clicks a button, the Click event routine is invoked. You place code in the Click event routine to perform any action you choose.
There are many ways to choose a command button at run time:
Use a mouse to click the button.
Move the focus to the button by pressing the TAB key, and then choose the button by pressing the SPACEBAR or ENTER.
Press an access key (ALT+ the underlined letter) for a command button.
Invoke the command button's Click event in code:
If the command button is the default command button for the form, pressing ENTER chooses the button, even if you change the focus to a different control other than a command button. At design time, you specify a default command button by setting that button's Default property to True.
If the command button is the default Cancel button for the form, pressing ESC chooses the button, even if you change the focus to another control. At design time, you specify a default Cancel button by setting that button's Cancel property to True.
All these actions cause Visual PL/B to invoke the Click event procedure.
![]() |