You are on page 1of 3

Public Class Form5

Private Sub Form5_Load(sender As System.Object, e As System.EventArgs) Handles


MyBase.Load
ListBox1.Items.Add("Name" & vbTab & "Height" & vbTab & "Weight" & vbTab & "BMI "&
vbtab & STATUS)

ListBox1.Items.Add("==============================================
=============")

End Sub

Private Sub btnCalculate_Click(sender As System.Object, e As System.EventArgs) Handles


btnCalculate.Click
Dim H As Double
Dim W As Double
Dim BMI As Double
Dim TotalHeight As Double = 0
Dim TotalWeight As Double = 0
Dim AverageHeight As Double
Dim AverageWeight As Double
Dim AverageBMI As Double
Dim status as String

Dim I As Integer
For I = 1 To 5
txtName.Text = InputBox("Enter std Name")
txtHeight.Text = InputBox("Enter your Height")
txtWeight.Text = InputBox("Enter your weight")

H = Val(txtHeight.Text)
W = Val(txtWeight.Text)
TotalHeight = TotalHeight + H
TotalWeight = TotalWeight + W

BMI = (W / (H * H))
txtBMI.Text = Str(BMI)
If (BMI <= 18.5) Then
Status=Underweight
'MsgBox("You are unedrwaeight")
ElseIf (BMI <= 24.9) Then
Status=Normal weight
' MsgBox("You are Normal weight")
ElseIf (BMI <= 29.9) Then
Status=Overweight
' MsgBox("yOU ARE OVER WEIGHT")
Else
Status=oBESS
'MsgBox("yOU ARE OBESS")
End If

ListBox1.Items.Add(txtName.Text & vbTab & txtHeight.Text & vbTab & txtWeight.Text &
vbTab & txtBMI.Text& vbtab & status)
Next
AverageHeight = TotalHeight / 5
AverageWeight = TotalWeight / 5
AverageBMI = (AverageWeight / (AverageHeight * AverageHeight))
Label5.Text = Str(AverageHeight)
Label6.Text = Str(AverageWeight)
Label7.Text = Str(AverageBMI)
If (BMI <= 18.5) Then
Label8.Text = "This class is under weight"
'MsgBox("You are unedrwaeight")
ElseIf (BMI <= 24.9) Then
Label8.Text = "This class is Normal weight"
' MsgBox("You are Normal weight")
ElseIf (BMI <= 29.9) Then
Label8.Text = "This class is over weight"
' MsgBox("yOU ARE OVER WEIGHT")
Else
Label8.Text = "This class is Obess"
'MsgBox("yOU ARE OBESS")
End If

End Sub

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles


Button1.Click

End Sub
Private Sub Label9_Click(sender As System.Object, e As System.EventArgs) Handles
Label9.Click

End Sub
End Class

You might also like