This Visual Basic Tutorial is all about The Radio Button And The CheckBox.
This section will help you learn how to use radiobuttons and checkboxes for presenting and retrieving user choices.
Radio buttons or also known as option buttons always work as part of a group. For instance, if you select one radio button in the group it immediately clears all the other radio buttons.
See the example below on how to use Radio Buttons
- From the Toolbox, drag two Radio Buttons controls and a Button into the form.
- In the Properties window, change the Text property of the RadioButton1 to “Male” and set the check property to true.
Take Note that when defining group of choices, always set one choice to be the default.
- In the Properties window, change the Text property of the RadioButton1 to “Female”
- In the form, double-click the button to fire the Button1_Click event handler in the Code Editor.
- In the Button1_Click event handler, add the following code:
Press f5 to run your project.
CheckBox control consists of a text label and a box in which the user can select. A check mark appears in the box when the user clicks the box.
See the example below on how to use a checkbox:
- From the Toolbox, drag a Button and three CheckBox controls onto the form.
- In the Properties Window, change the Text property of CheckBox1 to “Male” and CheckBox2 to “Female”.
- In the Properties window, change the Text property of Button1 to read Submit.
- In the form, double-click the button; this fire the Button1_Click event handler in the Code Editor.
- Add the following code to the Button1_Click event handler:
Readers might read also: