1 Attachment(s)
Re Post BMI Calculator Helps..
Actually this my 1st Coding then i actually change it to the new 1 but i found the value determine only turn to underweight only.
so could anyone help me here for my school project.
Bmi Calculator Code:
Public Class Form1
Private Sub BtnResult_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnResult.Click
Dim Weight As Integer = 0I
Dim Height As Integer = 0I
If Integer.TryParse(TxtWeight.Text, Weight) AndAlso Integer.TryParse(TxtHeight.Text, Height) Then
'Perform the calculations here.
Weight = Weight * 703
Height = Height * Height
Dim BMI As Integer = (Weight / Height)
'Do the check.
If BMI < 0 Then
LblShow.Text = "Error"
ElseIf BMI <= 18.5 Then
LblShow.Text = "Underweight"
ElseIf BMI <= 24.9 Then
LblShow.Text = "Normal"
ElseIf BMI <= 29.9 Then
LblShow.Text = "Overweight"
Else
LblShow.Text = "Obese"
End If
End If
End Sub
Private Sub BtnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnClear.Click
TxtHeight.Clear()
TxtWeight.Clear()
LblShow.Text = " "
End Sub
Private Sub BtnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnExit.Click
MessageBox.Show("Bye!!")
Me.Close()
End Sub
End Class
http://www.freeimagehosting.net/uplo...bc94fc34aa.jpg
Re: Re Post BMI Calculator Helps..
i googled the algorithm. try this:
BMIValue = (weight) / (height ^ 2)
Re: Re Post BMI Calculator Helps..
Yo that 1 is not working...
Re: Re Post BMI Calculator Helps..
That means the all the fonts slide off the left side of the screen ... so tilt the monitor to the right. Does that help?
That is probaly as helpful as saying yo that1 is not working? What does that mean? IS there an error when the process runs? Are the results different then what you expected? We can't read the program on you screen you need to give detials.
Re: Re Post BMI Calculator Helps..
@Gary : i got the unexpected result ... it keeps determine one only at the if selection .. don't know whether is about the calculation or the if statement.
could you fix it for me..
by your own coding and with reference i gave already.. i need to know what i already done / mistake.
Re: Re Post BMI Calculator Helps..
vb Code:
Public Class Form1
Private Sub BtnResult_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnResult.Click
Dim Weight As Decimal = 0D
Dim Height As Decimal = 0D
If Decimal.TryParse(TxtWeight.Text, Weight) AndAlso Decimal.TryParse(TxtHeight.Text, Height) Then
'Perform the calculations here.
Dim BMI As Decimal = CDec(Weight / (Height ^ 2))
'Do the check.
If BMI < 0 Then
LblShow.Text = "Error"
ElseIf BMI <= 18.5 Then
LblShow.Text = "Underweight"
ElseIf BMI <= 24.9 Then
LblShow.Text = "Normal"
ElseIf BMI <= 29.9 Then
LblShow.Text = "Overweight"
Else
LblShow.Text = "Obese"
End If
End If
End Sub
End Class
edit: weight should be entered in kg + height in metres
Re: Re Post BMI Calculator Helps..
You should be using DECIMAL not INTEGER because of the rounding to whole numbers using INTEGER.
So change everything to DECIMAL and it should work.
Computerman :)
ps. .paul. beat me to it.
Re: Re Post BMI Calculator Helps..
@.paul. : the output still get the unexpected Result. ? although it fix a lil but in the End after entering both value , it still place it as Underweight as i said in the previous and now i put up weight 170 and height 172 , it become under weight underweight.. it suppose to be obese or overweight.
Re: Re Post BMI Calculator Helps..
@computerman : Still the same. .. although it fix several problem.. the result still become the unexpected result.
Re: Re Post BMI Calculator Helps..
try: weight 170 and height 1.72
Re: Re Post BMI Calculator Helps..
.paul. are you sure that the BMI is Weight /Height^2, because when I tested it using whitefloux90 original formula, it worked.
Computerman :)
Re: Re Post BMI Calculator Helps..
BMI = Weight /Height^2 is the correct formula using kg + m
Re: Re Post BMI Calculator Helps..
@.paul. : not working man.. are you sure.. it just fix the function like underweight ,and Obese.. the rest still doesn't fix..
@computerman : ya, i prefer the formula i use it first 1.. taken from health website.
==
i still dont know wheres my mistake on making it. this has prolong too much ... but yet it still bring me problem on making the real function of this Pucking code.. including other guys help me on it still have the same problem..
1 Attachment(s)
Re: Re Post BMI Calculator Helps..
Re: Re Post BMI Calculator Helps..
Show me your code.
Computerman :)
Re: Re Post BMI Calculator Helps..