Question: Purpose: This Windows Desktop application allows the user to enter a height and weight and computes the user s body mass index. Program Procedures: The

Purpose: This Windows Desktop application allows the user to enter a height and weight and computes the users body mass index. Program Procedures: The user will enter a height and weight using either the imperial or metric system. Algorithms, Processing, and Conditions: The user first views a Windows application that displays a title, a BMI graphic, a ListBox object to select the imperial or metric system, and labels to enter information for the users height and weight. When the user selects imperial or metric and enters the height and weight, the Compute BMI button can be selected. This button should be disabled until the user enters a value for both the height and weight and selects a system. Hint: There is an event that can be used to execute code when the user tabs out of a control. Do not validate the data in these event procedures, only verify that the value was entered or selected. Call a separate sub procedure in each event procedure to determine if all data has been entered/selected and enable the button. A Sub procedure should be called to handle the imperial and metric BMI calculations using the following formulas: BMI =(Weight in Pounds /(Height in Inches * Height in Inches))*703 BMI = Weight in Kilograms /(Height in Meters * Height in Meters) Two Function procedures should be called from the Sub procedure in the item above based on the system selected. Each Function procedure will calculate the BMI for the appropriate system and return the Decimal value to the calling procedure. The original sub procedure will display the result. You cannot use variables declared outside of the function procedure. If you need data in the function, you must pass that data to the function as parameters. In other words, do not reference a variable decWeight that is declared outside of the function. If you need that variable's value, you must pass the variable as a parameter to the function.
This is my code
Public Class FrmBMIAPP
Private Const _strImperial As String = "Imperial"
Private Const _strMetric As String = "Metric"
Private Sub FrmBMIAPP_Load(sender As Object, e As EventArgs) Handles MyBase.Load
lstMesurement.Items.Add(_strImperial)
lstMesurement.Items.Add(_strMetric)
Threading.Thread.Sleep(5000)
btnCalculate.Enabled = False
End Sub
Private Sub ValidateUserInput()
btnCalculate.Enabled = IsInputValid()
End Sub
Private Function IsInputValid() As Boolean
Dim weightValid As Boolean = Double.TryParse(txtWeight.Text, New Double())
Dim heightValid As Boolean = Double.TryParse(txtHeight.Text, New Double())
Dim mesurementSelected As Boolean = lstMesurement.SelectedItem IsNot Nothing
Return weightValid AndAlso heightValid AndAlso LstMesurement_SelectedIndexChanged() IsNot Nothing
End Function
Private Function LstMesurement_SelectedIndexChanged() As Object
Throw New NotImplementedException()
End Function
Private Sub BtnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
Try
Dim Weight As Decimal = Decimal.Parse(txtWeight.Text)
Dim Height As Decimal = Decimal.Parse(txtHeight.Text)
Dim bmi As Decimal
If lstMesurement.SelectedItem.ToString()=_strImperial Then
bmi = CalculateBMIImperial(CDec(Weight), CDec(Height))
Else
bmi = CalculateBMIMetric(CDec(Weight), CDec(Height))
End If
lblResults.Text = "Your BMI is: " & Math.Round(bmi,2).ToString()
Catch ex As Exception
MessageBox.Show("Please enter Valid Numeric values for height and weight.", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Function CalculateBMIImperial(ByVal Weight As Decimal, ByVal Height As Decimal) As Decimal
Return (Weight /(Height * Height))*703
End Function
Private Function CalculateBMIMetric(ByVal Weight As Decimal, ByVal Height As Decimal) As Decimal
Return Weight /(Height * Height)
End Function
Private Sub TxtHeight_Leave(sender As Object, e As EventArgs) Handles txtHeight.Leave
ValidateUserInput()
End Sub
Private Sub TxtWeight_Leave(sender As Object, e As EventArgs) Handles txtWeight.Leave
ValidateUserInput()
End Sub
Private Sub LstMesurement_SelectedIndexChanged(sender As Object, e As EventArgs) Handles lstMesurement.SelectedIndexChanged
ValidateUserInput()
txtHeight.Text =""
txtWeight.Text =""
lblResults.Text =""
End Sub
Private Sub BtnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
Close()
End Sub
End Class
My issue is that my code is not working correctly. When the form runs the user is able to enter the height and weight in the text boxes but when the calculate button is clicked nothing happens. Please help

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!