Results 1 to 16 of 16

Thread: Re Post BMI Calculator Helps..

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2010
    Posts
    26

    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:
    1. Public Class Form1
    2.     Private Sub BtnResult_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnResult.Click
    3.  
    4.         Dim Weight As Integer = 0I
    5.         Dim Height As Integer = 0I
    6.         If Integer.TryParse(TxtWeight.Text, Weight) AndAlso Integer.TryParse(TxtHeight.Text, Height) Then
    7.  
    8.             'Perform the calculations here.
    9.  
    10.             Weight = Weight * 703
    11.             Height = Height * Height
    12.             Dim BMI As Integer = (Weight / Height)
    13.  
    14.             'Do the check.
    15.             If BMI < 0 Then
    16.                 LblShow.Text = "Error"
    17.             ElseIf BMI <= 18.5 Then
    18.                 LblShow.Text = "Underweight"
    19.             ElseIf BMI <= 24.9 Then
    20.                 LblShow.Text = "Normal"
    21.             ElseIf BMI <= 29.9 Then
    22.                 LblShow.Text = "Overweight"
    23.             Else
    24.                 LblShow.Text = "Obese"
    25.  
    26.             End If
    27.  
    28.  
    29.         End If
    30.  
    31.     End Sub
    32.     Private Sub BtnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnClear.Click
    33.  
    34.         TxtHeight.Clear()
    35.  
    36.         TxtWeight.Clear()
    37.  
    38.         LblShow.Text = " "
    39.  
    40.     End Sub
    41.     Private Sub BtnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnExit.Click
    42.  
    43.         MessageBox.Show("Bye!!")
    44.  
    45.         Me.Close()
    46.  
    47.     End Sub
    48.  
    49. End Class

    http://www.freeimagehosting.net/uplo...bc94fc34aa.jpg
    Attached Images Attached Images  

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,414

    Re: Re Post BMI Calculator Helps..

    i googled the algorithm. try this:

    BMIValue = (weight) / (height ^ 2)

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Aug 2010
    Posts
    26

    Re: Re Post BMI Calculator Helps..

    Yo that 1 is not working...

  4. #4
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    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.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Aug 2010
    Posts
    26

    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.

  6. #6
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,414

    Re: Re Post BMI Calculator Helps..

    vb Code:
    1. Public Class Form1
    2.  
    3.     Private Sub BtnResult_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnResult.Click
    4.         Dim Weight As Decimal = 0D
    5.         Dim Height As Decimal = 0D
    6.         If Decimal.TryParse(TxtWeight.Text, Weight) AndAlso Decimal.TryParse(TxtHeight.Text, Height) Then
    7.  
    8.             'Perform the calculations here.
    9.  
    10.             Dim BMI As Decimal = CDec(Weight / (Height ^ 2))
    11.  
    12.             'Do the check.
    13.             If BMI < 0 Then
    14.                 LblShow.Text = "Error"
    15.             ElseIf BMI <= 18.5 Then
    16.                 LblShow.Text = "Underweight"
    17.             ElseIf BMI <= 24.9 Then
    18.                 LblShow.Text = "Normal"
    19.             ElseIf BMI <= 29.9 Then
    20.                 LblShow.Text = "Overweight"
    21.             Else
    22.                 LblShow.Text = "Obese"
    23.  
    24.             End If
    25.  
    26.  
    27.         End If
    28.  
    29.     End Sub
    30. End Class

    edit: weight should be entered in kg + height in metres
    Last edited by .paul.; Oct 4th, 2010 at 03:04 PM.

  7. #7
    Hyperactive Member
    Join Date
    Dec 2007
    Location
    Somewhere else today
    Posts
    355

    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.
    It was much easier in VB6, but I am now liking Vb.Net alot more.

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Aug 2010
    Posts
    26

    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.

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Aug 2010
    Posts
    26

    Re: Re Post BMI Calculator Helps..

    @computerman : Still the same. .. although it fix several problem.. the result still become the unexpected result.

  10. #10
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,414

    Re: Re Post BMI Calculator Helps..

    try: weight 170 and height 1.72

  11. #11
    Hyperactive Member
    Join Date
    Dec 2007
    Location
    Somewhere else today
    Posts
    355

    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
    It was much easier in VB6, but I am now liking Vb.Net alot more.

  12. #12
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,414

    Re: Re Post BMI Calculator Helps..

    BMI = Weight /Height^2 is the correct formula using kg + m

  13. #13

    Thread Starter
    Junior Member
    Join Date
    Aug 2010
    Posts
    26

    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..

  14. #14
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,414

    Re: Re Post BMI Calculator Helps..

    works ok for me:
    Attached Files Attached Files

  15. #15
    Hyperactive Member
    Join Date
    Dec 2007
    Location
    Somewhere else today
    Posts
    355

    Re: Re Post BMI Calculator Helps..

    Show me your code.

    Computerman
    It was much easier in VB6, but I am now liking Vb.Net alot more.

  16. #16
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: Re Post BMI Calculator Helps..

    Please do not duplicate posts

    http://www.vbforums.com/showthread.php?t=627330
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width