Home

Check Boxes

 

Overview of Check Boxes

 

Introduction

A check box is a control that makes a statement true or false. To perform this validation, the control displays a small square box that the user can click. Here are examples:

The Options dialog box of Microsoft FrontPage

To start, the square box may be empty . If the user clicks it, a check mark appears in the square box Check Box. If the user clicks a check box that has a check mark in it, the check mark may be removed.

To let the user know what the check box control represents, the control is accompanied by a label that displays the statement. When the square box is empty *, the statement is false. When the square box is filled with a check mark T, the statement is true.

 

Creating a Check Box

To support check boxes, the .NET Framework provides the CheckBox class. To add a check box to your application at design time, from the Common Controls section of the Toolbox, yon can click the CheckBox control and click the form or a container on the form. Unlike the radio button but like the regular command button, a check box can safely be positioned directly on a form.

To programmatically create a check box, declare a variable of type CheckBox, use the new operator to allocate memory for it, and add it to the Controls collection of its holder. Here is an example:

Imports System.Drawing
Imports System.Windows.Forms

Module Exercise

    Public Class Starter
        Inherits Form

        Private chkValidate As CheckBox

        Dim components As System.ComponentModel.Container

        Public Sub New()
            InitializeComponent()
        End Sub

        Public Sub InitializeComponent()

            chkValidate = New CheckBox()

            Controls.Add(chkValidate)

        End Sub

    End Class

    Function Main() As Integer

        Dim frmStart As Starter = New Starter

        Application.Run(frmStart)

        Return 0
    End Function

End Module

Unlike the radio button that usually comes along with other radio buttons, a check box can appear by itself. Even when it comes in a group with others, the behavior of one check box is independent of the other check boxes, even if they belong to the same group.

Practical Learning Practical Learning: Introducing Check Boxes

  1. Start a new Windows Application named DaniloPizza1
  2. In the Solution Explorer, right-click Form1.vb and click Rename
  3. Type Exercise.vb and press Enter
  4. On the main menu, click Project -> Add New Item...
  5. In the Templates list, click Icon File
  6. Set the Name to pizza and click Add
  7. Using the Erase tool Erase, wipe its interior to erase its content
  8. Use the Ellipse tool and the black color to draw an oval shape
     
  9. Fill Fill it up with a brown color (the color on the right side of the black)
  10. Click the red color
  11. Click the Airbrush tool
  12. Click the option button and select the Medium brush
     
    Medium Air Brush
  13. Randomly click different parts of the shape
     
  14. To give the appearance of a crust, use the Pencil tool , click the black color, right-click the brown color, and draw a dark border around the shape
  15. With still the black and the brown colors, randomly click and right-click different points in the shape:
     
  16. Click the white color. Right-click the yellow color. Randomly click and right-click a few times in the shape
  17. Click the brown color again and click the Line tool
  18. Randomly draw horizontal, vertical, and dialog lines in the shape
     
  19. Right-click a white section in the drawing area, position the mouse on Current Icon Image Types, and click 16x16, 16 Colors
  20. Design it as follows:
     
  21. Save the icon and close it
  22. Use the Icon field of the form in the Properties window to assign the pizza.ico icon to the form
  23. Design the form as follows:
     
    Danilo Pizza - Design
     
    Control Text Name Additional Properties
    GroupBox GroupBox Pizza Size    
    RadioButton RadioButton Small rdoSmall  
    TextBox TextBox 8.95 txtSmall AlignText: Right
    RadioButton RadioButton Medium rdoMedium Checked: True
    TextBox TextBox 10.75 txtMedium AlignText: Right
    RadioButton RadioButton Large rdoLarge  
    TextBox TextBox 12.95 txtLarge AlignText: Right
    GroupBox GroupBox Side Orders    
    Label Label Qty    
    Label Label Unit Price    
    Label Label Sub Total    
    Label Label Bread Sticks    
    TextBox TextBox 0 txtQtyBread AlignText: Right
    TextBox TextBox 3.25 txtPriceBread AlignText: Right
    TextBox TextBox 0.00 txtTotalBread AlignText: Right
    ReadOnly: True
    Label Label Buffalo Wings    
    TextBox TextBox 0 txtQtyWings AlignText: Right
    TextBox TextBox 2.15 txtPriceWings AlignText: Right
    TextBox TextBox 0.00 txtTotalWings AlignText: Right
    ReadOnly: True
    GroupBox GroupBox Toppings    
    CheckBox CheckBox Pepperoni chkPepperoni  
    CheckBox CheckBox Sausage chkSausage  
    CheckBox CheckBox Extra Cheese chkExtraCheese  
    CheckBox CheckBox Olives chkOlives  
    CheckBox CheckBox Onions chkOnions  
    Label Label Each Topping    
    TextBox TextBox 0.45 txtEachTopping AlignText: Right
    GroupBox GroupBox Drinks    
    Label Label Qty    
    Label Label Unit Price    
    Label Label Sub Total    
    Label Label Soda Can    
    TextBox TextBox 0 txtQtyCan AlignText: Right
    TextBox TextBox 1.45 txtPriceCan AlignText: Right
    TextBox TextBox 0.00 txtTotalCan AlignText: Right
    ReadOnly: True
    Label Label Soda 20 Oz.    
    TextBox TextBox 0 txtQtySoda20 AlignText: Right
    TextBox TextBox 1.45 txtPriceSoda20 AlignText: Right
    TextBox TextBox 0.00 txtTotalSoda20 AlignText: Right
    ReadOnly: True
    Label Label Soda 2L Bottle    
    TextBox TextBox 0 txtQtySoda2L AlignText: Right
    TextBox TextBox 1.45 txtPriceSoda2L AlignText: Right
    TextBox TextBox 0.00 txtTotalSoda2L AlignText: Right
    ReadOnly: True
    Label Label Orange Juice    
    TextBox TextBox 0 txtQtyOJ AlignText: Right
    TextBox TextBox 2.25 txtPriceOJ AlignText: Right
    TextBox TextBox 0.00 txtTotalOJ AlignText: Right
    ReadOnly: True
    Label Label Water    
    TextBox TextBox 0 txtQtyWater AlignText: Right
    TextBox TextBox 1.25 txtPriceWater AlignText: Right
    TextBox TextBox 0.00 txtTotalWater AlignText: Right
    ReadOnly: True
    Button Button Close btnClose  
    Label Label Total Price    
    TextBox TextBox 0.00 txtTotalPrice AlignRight: Right
    ReadOnly: True
  24. Save everything

Check Box Characteristics

 

Checking a Check Box

By default, a check box appears empty, which makes its statement false. To make the statement true, the user can click it. There are three main ways you can use this property of a check box. To select a check box, you can set its Checked property to True. You can also do it programmatically as follows:

Public Sub InitializeComponent()

            chkValidate = New CheckBox()

            Controls.Add(chkValidate)

            chkValidate.Checked = True

End Sub

To find out if an item is selected, get the value of its Checked property. Another possibility consists of toggling the state of the check mark. For example, you can check or uncheck the check mark when the user clicks another button. To do this, you can simply negate the truthfulness of the control as follows.

Like the radio button, when a check box is clicked, the control fires a CheckedChanged event to let you know that it has been checked. This event is of type EventArgs. If the check box can display only two states, checked or unchecked, this event is enough.

Practical Learning Practical Learning: Configuring Check Boxes

  1. Right-click the form and click View Code
  2. Inside the class, create the following procedure:
     
    Public Class Exercise
    
        Private Sub CalculatePrice()
            Dim PriceSize As Double
            Dim PriceEachTopping As Double
            Dim BWings As Double
            Dim Bread As Double
            Dim SodaCan As Double
            Dim Soda20 As Double
            Dim Soda2L, OJ As Double
            Dim Water As Double
            Dim PriceToppings As Double
            Dim TotalOrder As Double
            Dim Pepperoni As Integer
            Dim Sausage As Integer
            Dim ExtraCheese As Integer
            Dim Onions As Integer
            Dim Olives As Integer
    
            Try
                ' Get the price of pizza depending on the selected size
                If rdoSmall.Checked = True Then
                    PriceSize = CDbl(txtSmall.Text)
                End If
    
                If rdoMedium.Checked = True Then
                    PriceSize = CDbl(txtMedium.Text)
                End If
    
                If rdoLarge.Checked = True Then
                    PriceSize = CDbl(txtLarge.Text)
                End If
            Catch ex As Exception
                MsgBox("The value you typed for the price of a pizza is invalid" & _
                                vbCrLf & "Please try again")
            End Try
    
            ' Get the price of a topping if it was selected
            If chkPepperoni.Checked = True Then
                Pepperoni = 1
            Else
                Pepperoni = 0
            End If
    
            If chkSausage.Checked = True Then
                Sausage = 1
            Else
                Sausage = 0
            End If
    
            If chkExtraCheese.Checked = True Then
                ExtraCheese = 1
            Else
                ExtraCheese = 0
            End If
    
            If chkOnions.Checked = True Then
                Onions = 1
            Else
                Onions = 0
            End If
    
            If chkOlives.Checked = True Then
                Olives = 1
            Else
                Olives = 0
            End If
    
            ' Get the price of each topping
            Try
                PriceEachTopping = CDbl(txtEachTopping.Text)
            Catch
                MsgBox("The value you typed for the price of a each topping is invalid" & _
                    vbCrLf & "Please try again")
            End Try
    
            PriceToppings = (Pepperoni + Sausage + ExtraCheese + _
                            Onions + Olives) * PriceEachTopping
    
            ' Calculate the price of the side dishes
            ' depending on the quantity entered
            BWings = CDbl(txtTotalWings.Text)
            Bread = CDbl(txtTotalBread.Text)
    
            ' Calculate the price of the drink(s)
            SodaCan = CDbl(txtTotalCan.Text)
            Soda20 = CDbl(txtTotalSoda20.Text)
            Soda2L = CDbl(txtTotalSoda2L.Text)
            OJ = CDbl(txtTotalOJ.Text)
            Water = CDbl(txtTotalWater.Text)
    
            TotalOrder = PriceSize + PriceToppings + BWings + Bread + _
                SodaCan + Soda20 + Soda2L + OJ + Water
            txtTotalOrder.Text = FormatNumber(TotalOrder)
    
        End Sub
    End Class
  3. Under the above procedure, create the following procedure:
     
    Private Sub rdoSmall_Click(ByVal sender As Object, _
                                   ByVal e As System.EventArgs) _
                                   Handles rdoSmall.Click, _
                                           rdoMedium.Click, _
                                           rdoMedium.Click, _
                                           chkExtraCheese.Click, _
                                           chkOlives.Click, _
                                           chkOnions.Click, _
                                           chkPepperoni.Click, _
                                           chkSausage.Click
    
            CalculatePrice()
    End Sub
  4. Under the above procedure, create the following procedure:
     
    Private Sub ItemPriceLeave(ByVal sender As Object, _
                                   ByVal e As System.EventArgs) _
                                   Handles txtSmall.Leave, _
                                   txtMedium.Leave, _
                                   txtLarge.Leave, _
                                   txtMedium.Leave, _
                                   txtLarge.Leave, _
                                   txtEachTopping.Leave, _
                                   txtQtyBread.Leave, _
                                   txtPriceBread.Leave, _
                                   txtQtyWings.Leave, _
                                   txtPriceWings.Leave, _
                                   txtQtyCan.Leave, _
                                   txtPriceCan.Leave, _
                                   txtQtySoda20.Leave, _
                                   txtPriceSoda20.Leave, _
                                   txtQtySoda2L.Leave, _
                                   txtPriceSoda2L.Leave, _
                                   txtQtyOJ.Leave, _
                                   txtPriceOJ.Leave, _
                                   txtQtyWater.Leave, _
                                   txtPriceWater.Leave
            Dim QtyBread As Integer
            Dim QtyWings As Integer
            Dim QtyCan As Integer
            Dim QtySoda20 As Integer
            Dim QtySoda2L As Integer
            Dim QtyOJ As Integer
            Dim QtyWater As Integer
    
            Dim PriceBread As Double
            Dim TotalBread As Double
            Dim PriceWings As Double
            Dim TotalWings As Double
            Dim PriceCan As Double
            Dim TotalCan As Double
            Dim PriceSoda20 As Double
            Dim TotalSoda20 As Double
            Dim PriceSoda2L As Double
            Dim TotalSoda2L As Double
            Dim PriceOJ As Double
            Dim TotalOJ As Double
            Dim PriceWater As Double
            Dim TotalWater As Double
    
            ' Retrieve the quantity set in the text box
            Try
                QtyBread = CInt(txtQtyBread.Text)
            Catch ex As Exception
                MsgBox("The value you entered for the quantify " & _
                       "of bread sticks is not valid" & _
                       vbCrLf & "Please try again!")
            End Try
    
            ' Get the unit price of the item
            Try
                PriceBread = CDbl(txtPriceBread.Text)
            Catch ex As Exception
                MsgBox("The value you entered for the price " & _
                       "of bread sticks is not valid" & _
                    vbCrLf & "Please try again!")
            End Try
    
            ' Calculate the sub-total of this item
            TotalBread = QtyBread * PriceBread
            ' Display the sub-total in the corresponding text box
            txtTotalBread.Text = TotalBread.ToString("F")
    
            Try
                PriceWings = CInt(txtQtyWings.Text)
            Catch ex As Exception
                MsgBox("The value you entered for the quantify " & _
                       "of orders of buffalo wings is not valid" & _
                    vbCrLf & "Please try again!")
            End Try
    
            Try
                PriceWings = CDbl(txtPriceWings.Text)
            Catch ex As Exception
                MsgBox("The value you entered for the price " & _
                       "of buffalo wings is not valid" & _
                    vbCrLf & "Please try again!")
            End Try
    
            TotalWings = QtyWings * PriceWings
            txtTotalWings.Text = TotalWings.ToString("F")
    
            Try
                QtyCan = CInt(txtQtyCan.Text)
            Catch ex As Exception
                MsgBox("The value you entered for the " & _
                       "quantify of soda cans is not valid" & _
                    vbCrLf & "Please try again!")
            End Try
    
            Try
                PriceCan = CDbl(txtPriceCan.Text)
            Catch ex As Exception
                MsgBox("The value you entered for the " & _
                       "price of soda cans is not valid" & _
                    vbCrLf & "Please try again!")
            End Try
    
            TotalCan = QtyCan * PriceCan
            txtTotalCan.Text = TotalCan.ToString("F")
    
            Try
                QtySoda20 = CInt(txtQtySoda20.Text)
            Catch ex As Exception
                MsgBox("The value you entered for the " & _
                       "quantify of soda 20 Oz. is not valid" & _
                    vbCrLf & "Please try again!")
            End Try
    
            Try
                PriceSoda20 = CDbl(txtPriceSoda20.Text)
            Catch ex As Exception
                MsgBox("The value you entered for the " & _
                       "price of soda 20 Oz. is not valid" & _
                    vbCrLf & "Please try again!")
            End Try
    
            TotalSoda20 = QtySoda20 * PriceSoda20
            txtTotalSoda20.Text = TotalSoda20.ToString("F")
    
            Try
                QtySoda2L = CInt(txtQtySoda2L.Text)
            Catch ex As Exception
                MsgBox("The value you entered for the quantify " & _
                       "of bottles of soda 2-litter is not valid" & _
                    vbCrLf & "Please try again!")
            End Try
    
            Try
                PriceSoda2L = CDbl(txtPriceSoda2L.Text)
            Catch ex As Exception
                MsgBox("The value you entered for the price " & _
                       "of a bottle of soda is not valid" & _
                    vbCrLf & "Please try again!")
            End Try
    
            TotalSoda2L = QtySoda2L * PriceSoda2L
            txtTotalSoda2L.Text = TotalSoda2L.ToString("F")
    
            Try
                QtyOJ = CInt(txtQtyOJ.Text)
            Catch ex As Exception
                MsgBox("The value you entered for the quantify " & _
                       "of a bottle of orange juice is not valid" & _
                    vbCrLf & "Please try again!")
            End Try
    
            Try
                PriceOJ = CDbl(txtPriceOJ.Text)
            Catch ex As Exception
                MsgBox("The value you entered for the price " & _
                       "of bottles of orange is not valid" & _
                    vbCrLf & "Please try again!")
            End Try
    
            TotalOJ = QtyOJ * PriceOJ
            txtTotalOJ.Text = TotalOJ.ToString("F")
    
            Try
                QtyWater = CInt(txtQtyWater.Text)
            Catch ex As Exception
                MsgBox("The value you entered for the quantify " & _
                       "of bottles of water is not valid" & _
                    vbCrLf & "Please try again!")
            End Try
    
            Try
                PriceWater = CDbl(txtPriceWater.Text)
            Catch ex As Exception
                MsgBox("The value you entered for the price " & _
                       "of bottle of water is not valid" & _
                    vbCrLf & "Please try again!")
            End Try
    
            TotalWater = QtyWater * PriceWater
            txtTotalWater.Text = TotalWater.ToString("F")
    
            CalculatePrice()
    End Sub
  5. In the Class Name combo box, select btnClose
  6. In the Method Name combo box, select Click and implement the event as follows:
     
    Private Sub btnClose_Click(ByVal sender As Object, _
                                   ByVal e As System.EventArgs) _
                                   Handles btnClose.Click
            End
    End Sub
  7. Execute the application and test the form. Here is an example:
     
    Danilo Pizza - Results
  8. Close the form and return to your programming environment

The Alignment of a Check Box

By default, the square box of a check control is positioned to the left side of its accompanying label. Instead of this default left position, you can change as you wish. The position of the round box with regards to its label is controlled by the CheckAlign property that of type ContentAlignment. To programmatically set the check alignment of a check box, you can call the ContentAlignment enumeration and select the desired value. Here is an example:

Public Sub InitializeComponent()

            chkValidate = New CheckBox()

            Controls.Add(chkValidate)

            chkValidate.CheckAlign = ContentAlignment.MiddleRight

End Sub

The Checked State of a Check Box

Instead of being definitely checked, you can let the user know that the decision of making the statement true or false is not complete. This means that a check box can display as "half-checked". In this case the check mark would appear as if it were disabled. This behavior is controlled through the CheckState property. To provide this functionality, assign the Indeterminate value to its CheckState property. You can do this programmatically as follows:

Public Sub InitializeComponent()

            chkValidate = New CheckBox()

            Controls.Add(chkValidate)

            chkValidate.CheckState = CheckState.Indeterminate

End Sub
Indeterminate check box

The CheckState property only allows setting the check box control as "undecided". If you actually want the user to control three states of the control as checked, half-checked, or unchecked, use the ThreeState property.

By setting the CheckState Boolean property to true, the user can click it two to three times to get the desired value. When this ability is given to the user, you can use or check the value of the Indeterminate property to find out whether the control is checked, half-checked, or unchecked.

Here is an example of specifying the check box control as being able to display one of three states:

Public Sub InitializeComponent()

            chkValidate = New CheckBox()

            Controls.Add(chkValidate)

            chkValidate.CheckAlign = ContentAlignment.MiddleRight
            chkValidate.CheckState = CheckState.Indeterminate
            chkValidate.ThreeState = True

End Sub

If a check box is configured to assume one of three states when it's clicked, that is, if the ThreeState property of a check button is set to True, when the user clicks such a button, the button acquires one of the available three states, which are Checked, Unchecked, or Indeterminate. This causes the control to fire a CheckStateChanged event. This event also is of type EventArgs. This means that it does not let you know the current state of the button. You would have to find it out yourself, which is easily done by getting the value of the CheckState property.

The Appearance of a Check Box

By default, a check box appears as a square box that gets a check mark when the user clicks it. Optionally, you can make a check box appear as a toggle button. In that case, the button would appear as a regular button. When the user clicks it, it appears down. If the user clicks it again, it becomes up.

To change the appearance of a check box, assign the Button or Normal value to its Appearance property. The Appearance values are defined in the Appearance enumeration. You can also do this programmatically as follows:

Public Sub InitializeComponent()

            chkValidate = New CheckBox()

            chkValidate.Appearance = Appearance.Button
            Controls.Add(chkValidate)

End Sub

Like the radio button, the check box control fires an AppearanceChanged event when the button's appearance changes from Normal to Button or vice-versa.

Practical Learning Practical Learning: Using the Appearance of a Check Box

  1. To start a new application, on the main menu, click File -> New Project...
  2. In the Templates list, click Windows Application and set the name to Logic1
  3. Click OK
  4. Design the form as follows:
     
    Control Text Name Font FlatStyle Appearance
    Label A   Microsoft Sans Serif, 24pt    
    Label B   Microsoft Sans Serif, 24pt    
    Label A ^ B lblOperation Microsoft Sans Serif, 24pt    
    CheckBox False chkOperand1 Microsoft Sans Serif, 18pt System Button
    CheckBox False chkOperand2 Microsoft Sans Serif, 18pt System Button
    CheckBox False chkResult Microsoft Sans Serif, 18pt System Button
    Button New Operation btnNewOperation Microsoft Sans Serif, 15.75pt    
    Button Check btnCheckOperation Microsoft Sans Serif, 18pt    
    Button Close btnClose Microsoft Sans Serif, 15.75pt    
  5. Double-click the top-left (False) button and implement its event as follows:
     
    Private Sub chkOperand1_CheckedChanged(ByVal sender As System.Object, _
                                               ByVal e As System.EventArgs) _
                                               Handles chkOperand1.CheckedChanged
            If chkOperand1.Checked = True Then
                chkOperand1.Text = "True"
            Else
                chkOperand1.Text = "False"
            End If
    End Sub
  6. In the Class Name combo box, select chkOperand2
  7. In the Method Name combo box, select CheckedChanged and implement its event as follows:
     
    Private Sub chkOperand2_CheckedChanged(ByVal sender As Object, _
                                               ByVal e As System.EventArgs) _
                                               Handles chkOperand2.CheckedChanged
            If chkOperand2.Checked = True Then
                chkOperand2.Text = "True"
            Else
                chkOperand2.Text = "False"
            End If
    End Sub
  8. In the Class Name combo box, select chkResult
  9. In the Method Name combo box, select CheckedChanged and implement its event as follows:
     
    Private Sub chkResult_CheckedChanged(ByVal sender As Object, _
                                             ByVal e As System.EventArgs) _
                                             Handles chkResult.CheckedChanged
            If chkResult.Checked = True Then
                chkResult.Text = "True"
            Else
                chkResult.Text = "False"
            End If
    End Sub
  10. In the Class Name combo box, select btnNewOperation
  11. In the Method Name combo box, select Click and implement its event as follows:
     
    Private Sub btnNewOperation_Click(ByVal sender As Object, _
                                          ByVal e As System.EventArgs) _
                                          Handles btnNewOperation.Click
            Dim strBooleanValues As String() = {"True", "False"}
            Dim strOperations As String() = {"A ^ B", "A V B"}
            Dim rndNumber As Random = New Random()
    
            chkOperand1.Text = strBooleanValues(rndNumber.Next(2))
            chkOperand2.Text = strBooleanValues(rndNumber.Next(2))
    
            If chkOperand1.Text = "True" Then
                chkOperand1.Checked = True
            Else
                chkOperand1.Checked = False
            End If
    
            If chkOperand2.Text = "True" Then
                chkOperand2.Checked = True
            Else
                chkOperand2.Checked = False
            End If
    
            lblOperation.Text = strOperations(rndNumber.Next(2))
    End Sub
  12. In the Class Name combo box, select btnCheckResult
  13. In the Method Name combo box, select Click and implement its event as follows:
     
    Private Sub btnCheckResult_Click(ByVal sender As Object, _
                                         ByVal e As System.EventArgs) _
                                         Handles btnCheckResult.Click
            ' Logical Conjunction
            If lblOperation.Text = "A ^ B" Then
                ' If A = true
                If chkOperand1.Checked = True Then
                    If chkOperand2.Checked = True Then
                        If chkResult.Checked = True Then
                            ' | A | B | A ^ B |
                            ' | T | T |   T   |
                            MsgBox("Bravo - Good Answer")
                        ElseIf chkResult.Checked = False Then
                            ' | A | B | A ^ B |
                            ' | T | T |   F   |
                            MsgBox("Wrong - Get it right next time!")
                        End If
                    ElseIf chkOperand2.Checked = False Then
                        If chkResult.Checked = False Then
                            ' | A | B | A ^ B |
                            ' | T | F |   F   |
                            MsgBox("Bravo - Good Answer")
                        ElseIf chkResult.Checked = True Then
                            ' | A | B | A ^ B |
                            ' | T | F |   T   |
                            MsgBox("Wrong - Get it right next time!")
                        End If
                    End If
                ElseIf chkOperand1.Checked = False Then
                    If chkOperand2.Checked = True Then
                        If chkResult.Checked = False Then
                            ' | A | B | A ^ B |
                            ' | F | T |   F   |
                            MsgBox("Bravo - Good Answer")
                        ElseIf chkResult.Checked = True Then
                            ' | A | B | A ^ B |
                            ' | F | T |   T   |
                            MsgBox("Wrong - Get it right next time!")
                        End If
                    ElseIf chkOperand2.Checked = False Then
                        If chkResult.Checked = False Then
                            ' | A | B | A ^ B |
                            ' | F | F |   F   |
                            MsgBox("Bravo - Good Answer")
                        ElseIf chkResult.Checked = True Then
                            ' | A | B | A ^ B |
                            ' | F | F |   T   |
                            MsgBox("Wrong - Get it right next time!")
                        End If
                    End If
                End If
            End If
    
            If lblOperation.Text = "A V B" Then ' Logical Disjunction
                ' If A = true
                If chkOperand1.Checked = True Then
                    If chkOperand2.Checked = True Then
                        If chkResult.Checked = True Then
                            ' | A | B | A V B |
                            ' | T | T |   T   |
                            MsgBox("Bravo - Good Answer")
                        ElseIf chkResult.Checked = False Then
                            ' | A | B | A V B |
                            ' | T | T |   F   |
                            MsgBox("Wrong - Get it right next time!")
                        End If
                    ElseIf chkOperand2.Checked = False Then
                        If chkResult.Checked = True Then
                            ' | A | B | A V B |
                            ' | T | F |   T   |
                            MsgBox("Bravo - Good Answer")
                        ElseIf chkResult.Checked = False Then
                            ' | A | B | A V B |
                            ' | T | F |   F   |
                            MsgBox("Wrong - Get it right next time!")
                        End If
                    End If
    
                ElseIf chkOperand1.Checked = False Then
                    If chkOperand2.Checked = True Then
                        If chkResult.Checked = True Then
                            ' | A | B | A V B |
                            ' | F | T |   T   |
                            MsgBox("Bravo - Good Answer")
                        ElseIf chkResult.Checked = False Then
                            ' | A | B | A V B |
                            ' | F | T |   F   |
                            MsgBox("Wrong - Get it right next time!")
                        End If
                    ElseIf chkOperand2.Checked = False Then
                        If chkResult.Checked = False Then
                            ' | A | B | A V B |
                            ' | F | F |   F   |
                            MsgBox("Wrong - Get it right next time!")
                        ElseIf chkResult.Checked = True Then
                            ' | A | B | A V B |
                            ' | F | F |   T   |
                            MsgBox("Wrong - Get it right next time!")
                        End If
                    End If
                End If
            End If
    End Sub
  14. In the Class Name combo box, select btnClose
  15. In the Method Name combo box, select Click and implement its event as follows:
     
    Private Sub btnClose_Click(ByVal sender As Object, _
                                   ByVal e As System.EventArgs) _
                                   Handles btnClose.Click
            End
    End Sub
  16. Return to the form

 

 

Previous Copyright 2008-2009, yevol.com Next