Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Visual Basic Programming Please help me program the following form as I have the

ID: 3693100 • Letter: V

Question

Visual Basic Programming

Please help me program the following form as I have the layout completed using Visual Studio 2010, I just need help from creating the procedure UpdateLabel and on. Thank you for your help.

Add a new form frmOption

Create the following control: 1. FORM: name: frmOption

GROUP BOX: name: gbRadioButtons name: gbCheckBoxes

RADIO BTN: name: rbLevel1 name: rbLevel2 name: rbLevel3 Place the three CHECK BOXES inside of the frachkbox frame

CHECK BOX: name: chkColors , name: chkMouse checked: true , name: chkSound

BTN BUTTON: name: btnExit

LABEL: name: lblChoice

Enter the following line of code into all of the checkbox & radio button event. Example:
     Private Sub chkSound_CheckedChanged(ByVal sender As System.Object,…..
          UpdateLabel()
     End Sub

Create a procedure called: UPDATELABEL PROCEDURES: (or subprograms) An event procedure is created for a control. A procedure is used to hold form wide code. Create a new procedure by going to the code window, finding a blank space between the “Sub Routines” and type in the name of the new procedure. Hit Enter and the “End Sub will automatically be created.

Enter the following code into the code window:

Create a string variable called “info”, default to a blank string.

In an if..else statement, check to see if the control “chkSound”’s Checked property is true. If it is true, assign the text “Sound: ON” to the string Info. If not, assign the text “Sound: OFF” to the string Info.

In an if..else statement, check to see if the control “chkMouse”’s Checked property is true. If it is true, append the text “Mouse: ON” to the string Info. If not, append the text “Mouse: OFF” to the string Info. Include a new line directive to the string.

In an if..else statement, check to see if the control “chkColors”’s Checked property is true. If it is true, append the text “Colors: ON” to the string Info. If not, append the text “Colors: OFF” to the string Info. Include a new line directive to the string.

In a simple if statement, check to see if the control “rbLevel1”’s Checked property is true. If it is true, append the text “Level 1: ON” to the string Info. If not, do nothing. Only one radio button in a group can be checked.

In a simple if statement, check to see if the control “rbLevel2”’s Checked property is true. If it is true, append the text “Level 2: ON” to the string Info.

In a simple if statement, check to see if the control “rbLevel3”’s Checked property is true. If it is true, append the text “Level 3: ON” to the string Info.

Assign the string Info to the text property of the lblChoice control.

Explanation / Answer

Public Class frmOption
    Public chkb1 As Boolean
    Public chkb2 As Boolean
    Public chkb3 As Boolean
    Public chkColors As Boolean
    Public chkMouse As Boolean
    Public chkSound As Boolean
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub

    Private Sub CheckBox2_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox2.CheckedChanged
        If (CheckBox2.CheckState = True) Then
            chkMouse = True
        End If
        UpdateLabel()
    End Sub

    Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
        If (CheckBox1.CheckState = True) Then
            chkColors = True
        End If
        UpdateLabel()
    End Sub
    Private Sub CheckBox3_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox3.CheckedChanged
        If (CheckBox3.CheckState = True) Then
            chkSound = True
        End If
        UpdateLabel()
    End Sub

    Private Sub RadioButton2_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton2.CheckedChanged
        If (RadioButton2.Checked = True) Then
            chkb3 = True
        End If
        UpdateLabel()
    End Sub

    Private Sub RadioButton1_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton1.CheckedChanged
        If (RadioButton1.Checked = True) Then
            chkb3 = True
        End If
        UpdateLabel()
    End Sub
    Private Sub RadioButton3_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton3.CheckedChanged
        If (RadioButton3.Checked = True) Then
            chkb3 = True
        End If
        UpdateLabel()
    End Sub
    Function UpdateLabel()
        Dim info As String
        info = ""

        If (chkSound = True) Then
            info = “Sound: ON”
        Else
            info = "Sound: OFF"
        End If

        If (chkMouse = True) Then
            info = “Mouse: ON”
        Else
            info = "Mouse: OFF"
        End If

        If (chkColors = True) Then
            info = “Colors: ON”
        Else
            info = "Colors: OFF"
        End If

        If (chkb1 = True) Then
            info = “Level 1: ON”
        End If

        If (chkb2 = True) Then
            info = “Level 2: ON”
        End If

        If (chkb1 = True) Then
            info = “Level 1: ON”
        End If

    End Function


End Class

// I used a boolean to keep track of changes in values. Feel free to ask any doubts.