How to Calculate BMI Using Visual Basic

Written by jim campbell
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Calculate BMI Using Visual Basic
BMI is used to calculate body fat. (watch youre weight image by Ivonne Wierink from

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.

Skill level:


  1. 1

    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

  2. 2

    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 68 Kilogram and 5 feet 6 inches is evaluated. The following converts the weight and saves it to the height variable: weight = 150 * 703

  3. 3

    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)

  4. 4

    Assign the BMI value to 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 finalises the calculation: BMI = Convert.ToInteger(height) MsgBox "The BMI is " & BMI

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.