Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub CalculateBMI()
- Dim name As String = String.Empty ' User name
- Dim height As String = String.Empty ' User height
- Dim weight As String = String.Empty ' User weight
- Dim BMI As String = String.Empty ' User BMI
- Do ' Input user name
- name = InputBox("Enter your name : ", "BMI CALC")
- If String.Equals(name, "-1") Then Exit Sub
- Loop Until Not String.IsNullOrWhiteSpace(name)
- Do ' Input user height
- height = InputBox("Enter your height (CM): ", "BMI CALC")
- If String.Equals(height, "-1") Then Exit Sub
- Loop Until Not String.IsNullOrWhiteSpace(height)
- Do ' Input user weight
- weight = InputBox("Enter your weight (KG) : ", "BMI CALC")
- If String.Equals(weight, "-1") Then Exit Sub
- Loop Until Not String.IsNullOrWhiteSpace(weight)
- 'Calculate BMI
- BMI = (CDbl(weight) / ((CDbl(height) / 100) ^ 2)).ToString
- MsgBox("Hello," & name & "." & vbNewLine &
- "Your BMI value is : " & Format(CDbl(BMI), "##.##"),
- MsgBoxStyle.OkOnly + MsgBoxStyle.Information + MsgBoxStyle.ApplicationModal + MsgBoxStyle.MsgBoxSetForeground,
- "Message")
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment