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

In this exercise, you’ll create a form that accepts the length and width of a re

ID: 3593496 • Letter: I

Question

In this exercise, you’ll create a form that accepts the length and width of a rectangle from the user and then calculates the area and perimeter of the rectangle. 1. Start a new project named AreaAndPerimeter in the Extra ExercisesChapter 04 directory. 2. Add labels, text boxes, and buttons to the default form and set the properties of the form and its controls so they appear as shown above. When the user presses the Enter key, the Click event of the Calculate button should fire. When the user presses the Esc key, the Click event of the Exit button should fire. 3. Create an event handler for the Click event of the Calculate button. This event handler should get the values the user enters for the length and width, calculate and display the area (length x width) and perimeter (2 x length + 2 x width), and move the focus to the Length text box. It should provide for decimal entries, but you can assume that the user will enter valid decimal values. 4. Create an event handler for the Click event of the Exit button that closes the form. 5. Test the application to be sure it works correctly.

Is this correct or am I missing something?

Public Class Form1

Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click

Dim length As Decimal = CDec(txtLength.Text)
Dim width As Decimal = CDec(txtWidth.Text)

Dim area As Decimal = width * length
Dim perimeter As Decimal = 2 * width + 2 * length

txtArea.Text = area.ToString
txtPerimeter.Text = perimeter.ToString

txtLength.Select()
End Sub

Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click

End Class

Explanation / Answer

Your program seems correct. However, if you are facing any particular error, then you can please let me know. I will be happy to help.

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