This is a sample program in vb.net that demonstrate checkbox control.
What is a checkbox?
A checkbox (in a graphical display) a small box that, when selected by the user, shows that a particular feature has been enabled or a particular option has been chosen or selected.
Unlike radio buttons, checkbox control allows the user to select or check multiple values or answer in a given set of choices.
This is somewhat similar to the previous tutorial that uses radio buttons, this program will ask you to select your favorite programming language but this time you can select as many as you want.
This tutorial will show us how.
- Open your visual studio 2010 or 2012.
- Select File menu and New Project.
- Kindly select Visual Basic then Windows Form Application.
- The image below will be the sample form design.
The form has the following controls:
1 groupbox control
5 checkboxes
10 labels
1 button
- Double click the Display Selected button (refer to the image above.)
Label6.Text = CheckBox1.Checked
Label7.Text = CheckBox2.Checked
Label8.Text = CheckBox3.Checked
Label9.Text = CheckBox4.Checked
Label10.Text = CheckBox5.Checked
Code explanation:
The code will be triggered if the user clicks the button. The value of the labels (Label6, Label7, Label8, Label9, and Label10) will be the value of the checkboxes, if the checkbox is selected then the value will be true or yes, false or no if not selected.
- Save and Test the project.