Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Lesson 5

Command Button Control


Command Button Properties
Events
Event Procedure

OBJECTIVES:
1. Familiarize with the command button procedure.
2. Simulate program using command buttons.
3. Create program integrated with the command button control.
COMMANDBUTTON CONTROL
CommandButton is a control that you press to tell a VB application to perform
a particular task. A button labeled Compute may tell the VB to computer for
the sum of two numbers and display the result on a Label. Below are the
common properties of a CommandButton.
Property

Description

BackColor

Specifies the CommandButtons background color. Programmer


selects a color from the Color Palette or specifies a color in
Hex format. Applicable only when Style property is set to 1:

Graphical.
Cancel

Determines whether the CommandButton gets a click event if


the user presses Esc.

Caption

Holds the text that appears on the CommandButton.

Default

Determines if the CommandButton responds to an Enter


keypress even if another has the focus.

Enabled

Boolean. Determines whether the CommandButton is active. A


disabled CommandButton is grayed out and cannot be pressed.

Font

Specifies the font of the CommandButton caption. Clicking


this property will invoke a font dialog box in which you can set
the font name, style, and size.

Height

Specifies the height of the CommandButton in twips.

Left

Specifies the number of twips from the CommandButtons left


edge to the Form windows left edge.

MousePointer Determines the image of the mouse cursor when the user

moves the mouse pointer over the CommandButton.


Picture

Holds the name of an icon graphic image that appears on the


CommandButton as long as the Style property is set to 1-

Graphical.
Style

Determines whether the CommandButton appears as a


standard Windows button (0: Standard) or a CommandButton
with a color and possible picture (1: Graphical)

TabIndex

Specifies the order of the CommandButton in the focus order.

TabStop

Boolean. Determines whether the CommandButton can receive


the focus.

ToolTipText

Holds the text that appears as a tooltip at runtime.

Top

Specifies the number of twips from the CommandButtons top


edge to the Form windows top edge.

Visible

Boolean. Determines whether the CommandButton appears


(True) or is hidden from the user (False) at runtime. Invisible
CommandButtons are only invisible at runtime.

Width

Holds the width of the CommandButton in twips.

Example of Command buttons with Icon

You might also like