CheckBox Control

Submitted by: 
Visitors have accessed this post 6363 times.

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", CheckBox2 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.

  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2. Dim country As String = ""
  4. If CheckBox1.Checked = True Then
  5. country = "Philippines"
  6. End If
  8. If CheckBox2.Checked = True Then
  9. country = country & " America"
  10. End If
  12. If CheckBox3.Checked = True Then
  13. country = country & " Canada"
  14. End If
  15. MsgBox(country & " is selected ")
  17. End Sub

We initialized 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.

Best Regards,

Engr. Lyndon R. Bermoy
IT Instructor/System Developer/Android Developer
STI College - Surigao City
Mobile: 09488225971
E-mail:[email protected]

Follow and add me in my Facebook Account:

Visit and like my page on Facebook at:

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.