I had discussed RadioButton a while ago and now I will introduce the CheckBox Control in VB.NET. CheckBox and RadioButton controls have a similar function: they allow the user to choose from a list of options. CheckBox
controls let the user pick a combination of options. In contrast, RadioButton
controls allow a user to choose from mutually exclusive options. They have the same popular event of .Checked
1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio: Go to File
, click New Project
, and choose Windows Application
2. Next, add three CheckBoxes namely CheckBox1
labeled as "Philippines
labeled as "America
", and CheckBox3
labeled as "Canada
". Add one Button named Button1
for choosing this country. You must design your layout like this:
3. Now, put this code in Button1_Click. This will choose the checked CheckBoxes you chose.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim country As String = ""
If CheckBox1.Checked = True Then
country = "Philippines"
If CheckBox2.Checked = True Then
country = country & " America"
If CheckBox3.Checked = True Then
country = country & " Canada"
country & " is selected ")
country As String = ""
to have a value regarding to our chosen CheckBoxes. If we check checkbox1, that is
CheckBox1.Checked = True
, the variable country holds the value of "Philippines
". If we check checkbox2, that is
CheckBox2.Checked = True
, the variable country holds the value of "America
", and lastly if we check checkbox3, that is
CheckBox3.Checked = True
. We used multiple ifs
to create a multi selection rather than If-else so that if we have two or three checkboxes checked, the country variable now holds two or three strings that will append and appear with the use of MessageBox. Thus, it will prompt the user that you have selected that country when you checked that certain CheckBoxes.
Download the source code below and try it! :)
For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below.
Engr. Lyndon R. Bermoy
IT Instructor/System Developer/Android Developer
STI College - Surigao City
Follow and add me in my Facebook Account: https://www.facebook.com/donzzsky
Visit and like my page on Facebook at: https://www.facebook.com/BermzISware