Holey_yan

[VB.NET] CalculateBMI

Sep 27th, 2015
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.17 KB | None | 0 0
  1. Private Sub CalculateBMI()
  2.     Dim name As String = String.Empty   ' User name
  3.     Dim height As String = String.Empty ' User height
  4.     Dim weight As String = String.Empty ' User weight
  5.     Dim BMI As String = String.Empty    ' User BMI
  6.  
  7.  
  8.     Do ' Input user name
  9.         name = InputBox("Enter your name : ", "BMI CALC")
  10.         If String.Equals(name, "-1") Then Exit Sub
  11.     Loop Until Not String.IsNullOrWhiteSpace(name)
  12.     Do ' Input user height
  13.         height = InputBox("Enter your height (CM): ", "BMI CALC")
  14.         If String.Equals(height, "-1") Then Exit Sub
  15.     Loop Until Not String.IsNullOrWhiteSpace(height)
  16.     Do ' Input user weight
  17.         weight = InputBox("Enter your weight (KG) : ", "BMI CALC")
  18.         If String.Equals(weight, "-1") Then Exit Sub
  19.     Loop Until Not String.IsNullOrWhiteSpace(weight)
  20.  
  21.     'Calculate BMI
  22.     BMI = (CDbl(weight) / ((CDbl(height) / 100) ^ 2)).ToString
  23.     MsgBox("Hello," & name & "." & vbNewLine &
  24.             "Your BMI value is : " & Format(CDbl(BMI), "##.##"),
  25.             MsgBoxStyle.OkOnly + MsgBoxStyle.Information + MsgBoxStyle.ApplicationModal + MsgBoxStyle.MsgBoxSetForeground,
  26.             "Message")
  27. End Sub
Advertisement
Add Comment
Please, Sign In to add comment