Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class BMICalculator
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNCalculate.Click
- If IsNumeric(TxtBoxHeight.Text) Then
- Else
- TxtBoxHeight.Text = ""
- MsgBox("Please enter a value for height")
- End If
- If IsNumeric(TxtBoxWeight.Text) Then
- Else
- TxtBoxWeight.Text = ""
- MsgBox("Please enter a value for weight")
- End If
- Dim BMI As Single
- Dim Height As Short
- Dim Weight As Short
- Height = CShort(TxtBoxHeight.Text)
- Weight = CShort(TxtBoxWeight.Text)
- BMI = (TxtBoxWeight.Text) / (TxtBoxHeight.Text * TxtBoxHeight.Text)
- BMI = CSng(BMI)
- Select Case BMI
- Case 0.0 To 18.5
- LblBMIAnalysis.Text = "You are underweight - Eat More"
- Case 18.5 To 29.9
- LblBMIAnalysis.Text = "You are normal - Keep Going"
- Case Is > 29.9
- LblBMIAnalysis.Text = "You are overweight - Exercise more and eat less"
- End Select
- BMIRESULT.Text = "Your BMI is" & BMI.ToString("F1")
- End Sub
- Private Sub BMICalculator_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement