VB6 Tutorial 13: The Command Button
You are going to learn about the command button control in this lesson. The command button control is a very common one. You need it every now and then in your program. So lets have a look at some properties including a run-time property.
Properties of the Command Button
- Cancel: Indicates whether a command button is the cancel button on the form. That means, if you press ESC key from keyboard, the CommandButton will be fired if the 'Cancel' property is set to true.
- Default: Indicates whether a command button is the default button on the form. That means, if you press ENTER key from keyboard, the CommandButton will be fired if the 'Default' property is set to true.
- MouseIcon: Sets a custom mouse icon.
- MousePointer: Sets the type of mouse pointer that will be shown when the mouse pointer is over the button.
- Picture: Sets an image to be displayed when the 'style' property is set to 1.
Run-time property of CommandButton
Value
The value property sets or returns the state of the control. That means , value is true if the CommandButton is pressed. This property is useful for programmatically clicking a button. Set the Name properties to cmdButton1 and cmdButton2. The default Name properties are Command1 and Command2.Example
Private Sub cmdButton1_Click() Print "Hello" End Sub Private Sub cmdButton2_Click() cmdButton1.Value = True End Sub
When you click on Button2, Button1 is clicked programmatically , then it prints "Hello".
About this post
Posted: 2018-04-01
By: vb6boy
Viewed: 825 times
Categories
Attachments
CommandButton.zip
Posted: 4/1/2018 10:47:23 AM
Size: 1,145 bytes
Loading Comments ...
Comments
No comments have been added for this post.
You must be logged in to make a comment.