# How to Calculate BMI Using Visual Basic

Save

The Body Mass Index (BMI) provides individuals and physicians with a guide for obesity. The BMI calculation determines if a person has a high ratio of fat versus height and weight. A high BMI indicates a person is approaching obesity, which can lead to more serious health conditions such as diabetes, heart disease and respiratory problems. A programmer can calculate BMI using Visual Basic (VB). The calculation is accomplished using the BMI algorithm and VB syntax.

• Create the Visual Basic variables. These variables hold the initial height and weight calculations. A third variable is created to contain the BMI value. The following code creates VB variables for the calculations:
Dim height As Decimal
Dim weight As Decimal
Dim BMI As Integer

• Convert the weight from pounds to kilograms. Kilograms is a standard unit for scientific calculations. The weight in pounds is converted by multiplying it with 703. In this example, a person who is 150 pounds and 5 feet 6 inches is evaluated. The following converts the weight and saves it to the height variable:
weight = 150 * 703

• Calculate the height. The height is first converted to inches. After it's converted to total inches, the weight is divided by the height twice. The following is how to calculate the height for the final BMI calculation (the apostrophe denotes code comments):
height = 5 12 + 6 '(multiply 12 times the feet and add the remaining inches)
height = weight / (5
12 + 6)
height = height (5 * 12 + 6)

• Assign the BMI value to the the variable, and send a message to the software user. The height value is the decimal value of the BMI. Height is converted to a whole number, and assigned to the BMI variable. The following finalizes the calculation:
BMI = Convert.ToInteger(height)
MsgBox "The BMI is " & BMI

## References

• Photo Credit watch youre weight image by Ivonne Wierink from Fotolia.com
Promoted By Zergnet

### You May Also Like

• How to Create a BMI Calculator

Creating a BMI calculator that will display your Body Mass Index on your computer rather than having to use an online version...

## Related Searches

Check It Out

### Geek Vs Geek: Robot battles, hoverboard drag race, and more

M
Is DIY in your DNA? Become part of our maker community.