BMI Calculator

 

A lot of people are obese now and it could affect their health seriously . Obesity has proven by the medical experts to be a one of the main factors that brings many adverse medical problems, including the  heart disease.   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.

For more information on BMI, please refer to the  Department of Health and Human Services

In order to calculate your BMI, you do not have to consult your doctor, you could just use a calculator or a home made computer program, this is exactly what I am showing you here. The 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 (you could indeed write a VB program for the conversion). You can program the BMI calculator in various ways, but I have opted to use a BMI function, because it looks clean and efficient.

The program is illustrated below and the output is shown in Figure 15.5

 

The Codes


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
         

 

[Back to VBToday]