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 enteredselected 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 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 FrmBMIAPPLoadsender As Object, e As EventArgs Handles MyBase.Load
lstMesurement.Items.AddstrImperial
lstMesurement.Items.AddstrMetric
Threading.Thread.Sleep
btnCalculate.Enabled False
End Sub
Private Sub ValidateUserInput
btnCalculate.Enabled IsInputValid
End Sub
Private Function IsInputValid As Boolean
Dim weightValid As Boolean Double.TryParsetxtWeightText, New Double
Dim heightValid As Boolean Double.TryParsetxtHeightText, New Double
Dim mesurementSelected As Boolean lstMesurement.SelectedItem IsNot Nothing
Return weightValid AndAlso heightValid AndAlso LstMesurementSelectedIndexChanged IsNot Nothing
End Function
Private Function LstMesurementSelectedIndexChanged As Object
Throw New NotImplementedException
End Function
Private Sub BtnCalculateClicksender As Object, e As EventArgs Handles btnCalculate.Click
Try
Dim Weight As Decimal Decimal.ParsetxtWeightText
Dim Height As Decimal Decimal.ParsetxtHeightText
Dim bmi As Decimal
If lstMesurement.SelectedItem.ToStringstrImperial Then
bmi CalculateBMIImperialCDecWeight CDecHeight
Else
bmi CalculateBMIMetricCDecWeight CDecHeight
End If
lblResults.Text "Your BMI is: & Math.RoundbmiToString
Catch ex As Exception
MessageBox.ShowPlease enter Valid Numeric values for height and weight.", "Invalid Input", MessageBoxButtons.OK MessageBoxIcon.Error
End Try
End Sub
Private Function CalculateBMIImperialByVal Weight As Decimal, ByVal Height As Decimal As Decimal
Return Weight Height Height
End Function
Private Function CalculateBMIMetricByVal Weight As Decimal, ByVal Height As Decimal As Decimal
Return Weight Height Height
End Function
Private Sub TxtHeightLeavesender As Object, e As EventArgs Handles txtHeight.Leave
ValidateUserInput
End Sub
Private Sub TxtWeightLeavesender As Object, e As EventArgs Handles txtWeight.Leave
ValidateUserInput
End Sub
Private Sub LstMesurementSelectedIndexChangedsender As Object, e As EventArgs Handles lstMesurement.SelectedIndexChanged
ValidateUserInput
txtHeight.Text
txtWeight.Text
lblResults.Text
End Sub
Private Sub BtnExitClicksender 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
