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

Question: use The following code with visual basic to add comments to everyline

ID: 3663736 • Letter: Q

Question

Question: use The following code with visual basic to add comments to everyline explaing what that particular line does. also explain what this program does.

Public Class Main_Form

Dim Augend As Integer
Dim Addend As Integer
Dim Subtrahend As Integer
Dim Minuend As Integer

Private Sub Main_Form_Load(sender As Object, e As EventArgs) Handles MyBase.Load

Randomize()

Augend = CInt(Int((999 * Rnd()) + 1))
Addend = CInt(Int((999 * Rnd()) + 1))
Subtrahend = CInt(Int((999 * Rnd()) + 1))
Minuend = CInt(Int((999 * Rnd()) + 1))

lbl_Augend.Text = Augend
lbl_Addend.Text = Addend
lbl_Subtrahend.Text = Subtrahend
lbl_Minuend.Text = Minuend

End Sub

Private Sub btn_Score_Click(sender As Object, e As EventArgs) Handles btn_Score.Click

Dim Sum As Integer
Dim Difference As Integer

Dim Input_Sum As Integer
Dim Input_Difference As Integer

Sum = Augend + Addend
Difference = Subtrahend - Minuend

Input_Sum = Convert.ToInt32(txt_Sum.Text)
Input_Difference = Convert.ToInt32(txt_Difference.Text)

If Input_Sum = Sum Then
txt_Sum.ForeColor = Color.Black
Else
txt_Sum.ForeColor = Color.Red
End If

If Input_Difference = Difference Then
txt_Difference.ForeColor = Color.Black
Else
txt_Difference.ForeColor = Color.Red
End If

End Sub

Private Sub btn_Close_Click(sender As Object, e As EventArgs) Handles btn_Close.Click
Me.Close()

End Sub

End Class

Explanation / Answer

I have added the comments as well as the functioning of the program in BOLD. Please read it.

Public Class Main_Form //Here Main_Form is a public class

    Dim Augend As Integer //Augend is a variable of integer type
    Dim Addend As Integer //Addend is a variable of interger type
    Dim Subtrahend As Integer //Subtrahend is a variable of integer type
    Dim Minuend As Integer //Minuend is a variable of interger type

    Private Sub Main_Form_Load(sender As Object, e As EventArgs) Handles MyBase.Load //Main_From_Load is a private Sub

        Randomize() // Initialize the random-number generator

        Augend = CInt(Int((999 * Rnd()) + 1)) //Generate random value between 1 and 999
        Addend = CInt(Int((999 * Rnd()) + 1)) //Generate random value between 1 and 999
        Subtrahend = CInt(Int((999 * Rnd()) + 1)) //Generate random value between 1 and 999
        Minuend = CInt(Int((999 * Rnd()) + 1)) //Generate random value between 1 and 999

        lbl_Augend.Text = Augend // Here we are setting text of lable
        lbl_Addend.Text = Addend // Here we are setting text of lable
        lbl_Subtrahend.Text = Subtrahend // Here we are setting text of lable
        lbl_Minuend.Text = Minuend // Here we are setting text of lable

    End Sub // end of private sub

    Private Sub btn_Score_Click(sender As Object, e As EventArgs) Handles btn_Score.Click //btn_Score_Click is a private Sub

        Dim Sum As Integer //Sum is a variable of integer type
        Dim Difference As Integer // Difference is a variable of integer type

        Dim Input_Sum As Integer //Input_Sum is a variable of integer type
        Dim Input_Difference As Integer //Input_Difference is a variable of interger type

        Sum = Augend + Addend //Addition of Augend and Addend variable is performed
        Difference = Subtrahend - Minuend // Substraction of Subtrahend and Minuend is performed

        Input_Sum = Convert.ToInt32(txt_Sum.Text) //Take a value from txt_sum textbox and convert it to 32-bit signed integer and save in variable Input_Sum
        Input_Difference = Convert.ToInt32(txt_Difference.Text) // Take a value from txt_Difference textbox and convert it to 32-bit signed integer and save in variable Input_Difference

        If Input_Sum = Sum Then
            txt_Sum.ForeColor = Color.Black // If value of variable Input_Sum is equal to Sum variable then change the txt_sum box foreground color to black
        Else
            txt_Sum.ForeColor = Color.Red // If value of variable Input_Sum is not equal to Sum variable then change the txt_sum box foreground color to Red
        End If

        If Input_Difference = Difference Then
            txt_Difference.ForeColor = Color.Black // If value of variable Input_Difference is equal to Difference variable then change the txt_Difference box foreground color to black
        Else
            txt_Difference.ForeColor = Color.Red // If value of variable Input_Difference is not equal to Difference variable then change the txt_Difference box foreground color to red
        End If

    End Sub // end of private sub

    Private Sub btn_Close_Click(sender As Object, e As EventArgs) Handles btn_Close.Click
        Me.Close()

    End Sub

End Class

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote