The btnSum_Click event handler has an error. (using 1, 2 and 3 as your test numb
ID: 668591 • Letter: T
Question
The btnSum_Click event handler has an error.
(using 1, 2 and 3 as your test numbers). Fix the error so the application correctly displays the sum of the numbers. Describe what you had to do to fix the error.
Public Class Form1
Private Sub btnSum_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSum.Click
Dim sum As Single
sum = CSng(txtNum1.Text & txtNum2.Text & txtNum3.Text)
lblSum.Text = sum.ToString
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
' Close the form.
Me.Close()
End Sub
Private Sub txtNum1_TextChanged(sender As Object, e As EventArgs) Handles txtNum1.TextChanged
End Sub
Private Sub lblSum_Click(sender As Object, e As EventArgs) Handles lblSum.Click
End Sub
End Class
Explanation / Answer
Public Class Form1
Private Sub btnSum_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSum.Click
Dim sum As Single
sum = CSng(txtNum1.Text & txtNum2.Text & txtNum3.Text)
lblSum.Text = sum.ToString
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
' Close the form.
Me.Close()
End Sub
End Class
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.