Question

Create an application that calculates and displays the area of a rectangle in both square feet...

Create an application that calculates and displays the area of a rectangle in both square feet and square yards. The user will provide the rectangle’s length and width, both measured in feet.

a. Prepare a Planning Chart for the application.

b. Draw a sketch of an appropriate interface. Be sure to follow the GUI design guidelines covered in the chapter. The guidelines are summarized in Figure 2-20. (If you want to include an image in the interface, you can either use your own image file or download an image file from openclipart.org. When downloading from openclipart.org, be sure to use the SMALL IMAGE (.PNG) button.)

c. Create a Windows Forms application. Use the following names for the project and solution, respectively: Area Project and Area Solution. Save the application in the VB2017\Chap02 folder. Change the appropriate properties of the form. Also, be sure to verify the name of the startup form.

d. Use your Planning Chart as a guide when building the interface. e. Code the Exit button. (You do not need to code the button that performs the two calculations and displays the results.) Save the solution and then start the application. Test the access keys, tab order, and Exit button and then close the solution.

Homework Answers

Answer #1

==> Screenshot of the Project/Solution name

==> Screenshot of the form component/variable names

MainForm.vb

Public Class MainForm

    '' Button exit click procedure
    Private Sub btn_exit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_exit.Click
        Me.Close()

    End Sub

    '' Button reset click procedure
    Private Sub btn_reset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_reset.Click
        tb_length.Text = ""
        tb_width.Text = ""
        tb_area_sqfeet.Text = ""
        tb_area_sqYards.Text = ""
    End Sub

    '' Button calculate click procedure
    Private Sub btn_calculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_calculate.Click

        '' checking whether both the inputs were given or not
        If tb_length.Text.Equals("") Then
            MessageBox.Show("Please enter the length of the Rectangle", "Message")
        ElseIf tb_width.Text.Equals("") Then
            MessageBox.Show("Please enter the width of the Rectangle", "Message")
        Else
            Dim length, width, areaInfeet, areaInYards As Double

            Double.TryParse(tb_length.Text, length)
            Double.TryParse(tb_width.Text, width)

            areaInfeet = length * width
            areaInYards = areaInfeet * 0.11111

            tb_area_sqfeet.Text = areaInfeet.ToString
            tb_area_sqYards.Text = areaInYards.ToString

        End If
    End Sub

    '' Form load procedure
    Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        tb_area_sqfeet.ReadOnly = True
        tb_area_sqYards.ReadOnly = True
        MaximizeBox = False
    End Sub
End Class

MainForm.Designer.vb

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class MainForm
    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.grpbox_input = New System.Windows.Forms.GroupBox()
        Me.tb_width = New System.Windows.Forms.TextBox()
        Me.tb_length = New System.Windows.Forms.TextBox()
        Me.lbl_width = New System.Windows.Forms.Label()
        Me.lbl_length = New System.Windows.Forms.Label()
        Me.grpbox_output = New System.Windows.Forms.GroupBox()
        Me.tb_area_sqYards = New System.Windows.Forms.TextBox()
        Me.tb_area_sqfeet = New System.Windows.Forms.TextBox()
        Me.lbl_area_sqYards = New System.Windows.Forms.Label()
        Me.lbl_area_sqfeet = New System.Windows.Forms.Label()
        Me.btn_calculate = New System.Windows.Forms.Button()
        Me.btn_reset = New System.Windows.Forms.Button()
        Me.btn_exit = New System.Windows.Forms.Button()
        Me.grpbox_input.SuspendLayout()
        Me.grpbox_output.SuspendLayout()
        Me.SuspendLayout()
        '
        'grpbox_input
        '
        Me.grpbox_input.Controls.Add(Me.tb_width)
        Me.grpbox_input.Controls.Add(Me.tb_length)
        Me.grpbox_input.Controls.Add(Me.lbl_width)
        Me.grpbox_input.Controls.Add(Me.lbl_length)
        Me.grpbox_input.Location = New System.Drawing.Point(55, 51)
        Me.grpbox_input.Name = "grpbox_input"
        Me.grpbox_input.Size = New System.Drawing.Size(244, 146)
        Me.grpbox_input.TabIndex = 0
        Me.grpbox_input.TabStop = False
        Me.grpbox_input.Text = "Input Dimensions of Rectangle"
        '
        'tb_width
        '
        Me.tb_width.Location = New System.Drawing.Point(109, 99)
        Me.tb_width.Name = "tb_width"
        Me.tb_width.Size = New System.Drawing.Size(114, 20)
        Me.tb_width.TabIndex = 2
        '
        'tb_length
        '
        Me.tb_length.Location = New System.Drawing.Point(109, 46)
        Me.tb_length.Name = "tb_length"
        Me.tb_length.Size = New System.Drawing.Size(114, 20)
        Me.tb_length.TabIndex = 1
        '
        'lbl_width
        '
        Me.lbl_width.AutoSize = True
        Me.lbl_width.Location = New System.Drawing.Point(11, 102)
        Me.lbl_width.Name = "lbl_width"
        Me.lbl_width.Size = New System.Drawing.Size(92, 13)
        Me.lbl_width.TabIndex = 1
        Me.lbl_width.Text = "Enter width in feet"
        '
        'lbl_length
        '
        Me.lbl_length.AutoSize = True
        Me.lbl_length.Location = New System.Drawing.Point(11, 49)
        Me.lbl_length.Name = "lbl_length"
        Me.lbl_length.Size = New System.Drawing.Size(96, 13)
        Me.lbl_length.TabIndex = 0
        Me.lbl_length.Text = "Enter length in feet"
        '
        'grpbox_output
        '
        Me.grpbox_output.Controls.Add(Me.tb_area_sqYards)
        Me.grpbox_output.Controls.Add(Me.tb_area_sqfeet)
        Me.grpbox_output.Controls.Add(Me.lbl_area_sqYards)
        Me.grpbox_output.Controls.Add(Me.lbl_area_sqfeet)
        Me.grpbox_output.Location = New System.Drawing.Point(53, 237)
        Me.grpbox_output.Name = "grpbox_output"
        Me.grpbox_output.Size = New System.Drawing.Size(246, 127)
        Me.grpbox_output.TabIndex = 1
        Me.grpbox_output.TabStop = False
        Me.grpbox_output.Text = "Output"
        '
        'tb_area_sqYards
        '
        Me.tb_area_sqYards.Location = New System.Drawing.Point(124, 87)
        Me.tb_area_sqYards.Name = "tb_area_sqYards"
        Me.tb_area_sqYards.Size = New System.Drawing.Size(100, 20)
        Me.tb_area_sqYards.TabIndex = 11
        Me.tb_area_sqYards.TabStop = False
        '
        'tb_area_sqfeet
        '
        Me.tb_area_sqfeet.Location = New System.Drawing.Point(124, 39)
        Me.tb_area_sqfeet.Name = "tb_area_sqfeet"
        Me.tb_area_sqfeet.Size = New System.Drawing.Size(100, 20)
        Me.tb_area_sqfeet.TabIndex = 10
        Me.tb_area_sqfeet.TabStop = False
        '
        'lbl_area_sqYards
        '
        Me.lbl_area_sqYards.AutoSize = True
        Me.lbl_area_sqYards.Location = New System.Drawing.Point(14, 90)
        Me.lbl_area_sqYards.Name = "lbl_area_sqYards"
        Me.lbl_area_sqYards.Size = New System.Drawing.Size(85, 13)
        Me.lbl_area_sqYards.TabIndex = 1
        Me.lbl_area_sqYards.Text = "Area in sq. yards"
        '
        'lbl_area_sqfeet
        '
        Me.lbl_area_sqfeet.AutoSize = True
        Me.lbl_area_sqfeet.Location = New System.Drawing.Point(13, 42)
        Me.lbl_area_sqfeet.Name = "lbl_area_sqfeet"
        Me.lbl_area_sqfeet.Size = New System.Drawing.Size(78, 13)
        Me.lbl_area_sqfeet.TabIndex = 0
        Me.lbl_area_sqfeet.Text = "Area in sq. feet"
        '
        'btn_calculate
        '
        Me.btn_calculate.Location = New System.Drawing.Point(33, 397)
        Me.btn_calculate.Name = "btn_calculate"
        Me.btn_calculate.Size = New System.Drawing.Size(75, 23)
        Me.btn_calculate.TabIndex = 3
        Me.btn_calculate.Text = "&Calculate"
        Me.btn_calculate.UseVisualStyleBackColor = True
        '
        'btn_reset
        '
        Me.btn_reset.Location = New System.Drawing.Point(141, 397)
        Me.btn_reset.Name = "btn_reset"
        Me.btn_reset.Size = New System.Drawing.Size(75, 23)
        Me.btn_reset.TabIndex = 4
        Me.btn_reset.Text = "&Reset"
        Me.btn_reset.UseVisualStyleBackColor = True
        '
        'btn_exit
        '
        Me.btn_exit.Location = New System.Drawing.Point(246, 397)
        Me.btn_exit.Name = "btn_exit"
        Me.btn_exit.Size = New System.Drawing.Size(75, 23)
        Me.btn_exit.TabIndex = 5
        Me.btn_exit.Text = "E&xit"
        Me.btn_exit.UseVisualStyleBackColor = True
        '
        'MainForm
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(380, 432)
        Me.Controls.Add(Me.btn_exit)
        Me.Controls.Add(Me.btn_reset)
        Me.Controls.Add(Me.btn_calculate)
        Me.Controls.Add(Me.grpbox_output)
        Me.Controls.Add(Me.grpbox_input)
        Me.Name = "MainForm"
        Me.Text = "Rectangle Area Calculator"
        Me.grpbox_input.ResumeLayout(False)
        Me.grpbox_input.PerformLayout()
        Me.grpbox_output.ResumeLayout(False)
        Me.grpbox_output.PerformLayout()
        Me.ResumeLayout(False)

    End Sub
    Friend WithEvents grpbox_input As System.Windows.Forms.GroupBox
    Friend WithEvents tb_width As System.Windows.Forms.TextBox
    Friend WithEvents tb_length As System.Windows.Forms.TextBox
    Friend WithEvents lbl_width As System.Windows.Forms.Label
    Friend WithEvents lbl_length As System.Windows.Forms.Label
    Friend WithEvents grpbox_output As System.Windows.Forms.GroupBox
    Friend WithEvents tb_area_sqYards As System.Windows.Forms.TextBox
    Friend WithEvents tb_area_sqfeet As System.Windows.Forms.TextBox
    Friend WithEvents lbl_area_sqYards As System.Windows.Forms.Label
    Friend WithEvents lbl_area_sqfeet As System.Windows.Forms.Label
    Friend WithEvents btn_calculate As System.Windows.Forms.Button
    Friend WithEvents btn_reset As System.Windows.Forms.Button
    Friend WithEvents btn_exit As System.Windows.Forms.Button

End Class

OUTPUT

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Lab: RectClass (constructor) Code in C++ This program creates a Rectangle object, then displays the rectangle's...
Lab: RectClass (constructor) Code in C++ This program creates a Rectangle object, then displays the rectangle's length, width, and area Define an overloaded constructor and use it when creating the Rectangle object instead of using the setters. Change this program to calculate and display the rectangle's perimeter. Example: In feet, how wide is your house? 20 In feet, how long is your house? 25 The house is 20.00 feet wide. The house is 25.00 feet long. The house has 500.00...
Create and use an enumeration create an enumeration and use it in a test application. 1....
Create and use an enumeration create an enumeration and use it in a test application. 1. Import the project named ch13 ex 2 Enumeration that's in the ex starts folder, 2. Create an enumeration named CustomerType. This enumeration should contain constants that represent three types of customers: retail. trade, and college. Use an enumeration 3. open the Customer Type App class. Then, add a method to this class that returns a discount percent C10 for retail. 30 for trade. and.20...
In Assignment 1, you created a program for Marshall’s Murals that prompts a user for the...
In Assignment 1, you created a program for Marshall’s Murals that prompts a user for the number of interior and exterior murals scheduled to be painted during the next month. The program computes the expected revenue for each type of mural when interior murals cost $500 each and exterior murals cost $750 each. In this assignment, you are going to design a GUI version using Visual Studio Form. The programs prompt a user for the number of interior and exterior...
I've posted this question like 3 times now and I can't seem to find someone that...
I've posted this question like 3 times now and I can't seem to find someone that is able to answer it. Please can someone help me code this? Thank you!! Programming Project #4 – Programmer Jones and the Temple of Gloom Part 1 The stack data structure plays a pivotal role in the design of computer games. Any algorithm that requires the user to retrace their steps is a perfect candidate for using a stack. In this simple game you...
Complete a Java program named ARMgr that maintains customer accounts receivable in a database. The code...
Complete a Java program named ARMgr that maintains customer accounts receivable in a database. The code to initialize the CustomerAccountsDB database table and add a set of customer accounts is provided. Finish the code in these 3 methods in CustomerAccountDB.java to update or query the database: -purchase(double amountOfPurchase) -payment(double amountOfPayment) -getCustomerName() Hint: For getCustomerName(), look at the getAccountBalance() method to see an example of querying data from the database. For the purchase() and payment() methods, look at the addCustomerAccount() method...
Sign In INNOVATION Deep Change: How Operational Innovation Can Transform Your Company by Michael Hammer From...
Sign In INNOVATION Deep Change: How Operational Innovation Can Transform Your Company by Michael Hammer From the April 2004 Issue Save Share 8.95 In 1991, Progressive Insurance, an automobile insurer based in Mayfield Village, Ohio, had approximately $1.3 billion in sales. By 2002, that figure had grown to $9.5 billion. What fashionable strategies did Progressive employ to achieve sevenfold growth in just over a decade? Was it positioned in a high-growth industry? Hardly. Auto insurance is a mature, 100-year-old industry...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary rivals? How will the acquisition of Reebok by Adidas impact the structure of the athletic shoe industry? Is this likely to be favorable or unfavorable for New Balance? 2- What issues does New Balance management need to address? 3-What recommendations would you make to New Balance Management? What does New Balance need to do to continue to be successful? Should management continue to invest...