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 9 Option and Checks

This tutorial is about learning about option buttons and check boxes, also it will teach you about frames. As frames are major part of using option buttons. This is my opinion. First i will show you how to use the check boxes. First click and drag the check box button so that you have two check boxes.
Example check box
When you double click one of the check boxes it brings you to the code window. Here it automatically makes it a click. Which this is the most useful at the moment. You can put what you want it to do here. So lets say you ask a question "Are you male or female?" You can put this in a label and the two check boxes you can change the captions to "Male" and "Female". Then if you double click on the "Male" and in the opening and closing you can put "Sex = 1" and in the "Female" one write "Sex = 2".
Now add another label and a command button. Here we will add a little pieace of code don't worry about it now as I will explain about it more later. Copy and paste this in the code window.
Private Sub Command1_Click()
If Sex = 1 Then
Label2.Caption = "Your a Man"
ElseIf Sex = 2 Then
Label2.Caption = "Your a women"
End If
End Sub

Now add two Option buttons. As you see when you press F5 you can click both, both are selected. Which is not what you want so Time to get rid of those option buttons and add a frame. Now once you have your frame what you need to do is add two option buttons inside the frame. Once this is done press F5 and see what happens when you click them. As you should be able to see they don't stay clicked. These also work the same as the check boxes try it out and see.
Example both