Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home4/sambenne/public_html/samsvb/includes/dbc.php on line 3
Visual Basic 6 Tutorials

Lesson 8 Command Buttons

Here is where the fun starts as we make a very simple program. First lets learn about the command buttons. The command buttons (CB) Are very important in some programs as without these some programs wont function. These are very easy to edit as all you can really edit is its name and caption. So create a button like the other components and name it "cmdSend", without the quotation marks. Now change the caption to "Send".

To the right of this add a textbox call "txtSend" and clear the text. Next to that add a label called "lblSent" with no text in that. You should have something like this:
Example simple program
Lets add some code. Double click the command button and you should see the code window.
Example simple program
Now what we are going to do is basically make the label caption equal to the text box and clear the text box. Which would make it look as though it has sent the information from to another. So to do this we need to write.
Private Sub cmdSend_Click()
lblSent.caption = txtSend.text
txtSend.text = ""
cmdSend.caption = "Sent"
End Sub

The Private Sub tells the program what type of job its doing. The cmdSend_Click() says what component is being used and how. (name).caption or (name).text tells the program what property that is being used or changed. You shoild off seen when you pressed the "." that some options appear that you can use. These option are specific to that component i.e. thoses are the only ones that will work.

Now if you press F5 whilst on your program a new window should appear with What you created. Now what you should do is type your name in the text box and then press the button.
Example simple program

Example simple program
Well Done you have created your first program.