Results 1 to 2 of 2

Thread: How do I convert grams to calories ?

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2011
    Posts
    2

    How do I convert grams to calories ?

    Users enter (in text boxes) the grams of fat, the grams of carbohydrates, and the grams of protein.

    Each gram of fat is nine calories; a gram of protein or carbohydrate is four calories.

    How can I write this ?

    Thanks

  2. #2
    Junior Member Pascal.Scholtes's Avatar
    Join Date
    Jun 2005
    Location
    Saarbrücken / Germany
    Posts
    26

    Re: How do I convert grams to calories ?

    intCalories = txtFat.Text * 9 + (txtCarbohydrates.Text + txtProtein.Text) * 4

    Make sure that the user entered valid values into the textbox. SetWindowLong from the API i.c.w. "ES_NUMBER" is a possible solution for.
    Look busy. Jesus is coming.

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