Thursday, December 22, 2011

BMI Calculator

A lot of people are obese now and it could affect their health seriously . If your BMI is more than 30, you are considered obese. You can refer to the following range of BMI values for your weight status.
  • Underweight = <18.5
  • Normal weight = 18.5-24.9
  • Overweight = 25-29.9
  • Obesity = BMI of 30 or greater
This BMI calculator is a Visual Basic program that can calculate the body mass index, or BMI of a person based  on the body weight in kilogram and the body height in meter. BMI can be calculated using the formula    weight/( height )2, where weight is measured in kg and height in meter. If you only know your weight and height in lb and feet, then you need to convert them to the metric system. 


The Code
Private Sub Command1_Click()
    Label4.Caption = BMI(Text1.Text, Text2.Text)
End Sub
Private Function BMI(height, weight)
      BMIValue = (weight) / (height ^ 2)
      BMI = Format(BMIValue, "0.00")
End Function

No comments: