VB6 Tutorial 13: The Command Button

Posted On 2018-04-01 by VB6Boy
Keywords:
Tags: VB6 Tutorials Windows
Views: 48

Title Uploaded Size
CommandButton.zip 4/1/2018 10:47:23 AM 1,145


Looking for the more of the VB6 Tutorial? Here is the tutorial index.

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".

Looking for the more of the VB6 Tutorial? Here is the tutorial index.


About the Author

VB6Boy has posted a total of 71 articles.


Comments On This Post

No comments on this post yet!


Do you have a thought relating to this post? You can post your comment here. If you have an unrelated question, you can use the Q&A section to ask it.

Or you can drop a note to the administrators if you're not sure where you should post.


Your IP address is:23.20.165.182

Before you can post, you need to prove you are human. If you log in, this test goes away.




Code Links