Very Very Newbie Simple Question

nunkaboy

Member
cAN ANYONE POINT ME IN RIGHT DIRECTION
I SIMPLY WANT TO HAVE A FORM TO INPUT 2 NUMBERS AND THEN CLICK A BUTTON TO CONVERT
ITS A BMI CONVERTER SO I WANT TO INPUT HEIGHT IN MTRS AND WEIGHT IN KGS AND THEN CALC BMI
I KNOW ITS A SIMPLE BUT MY HEAD IS READY TO EXPLODE
 

Zenerdiode

Active Member
Licensed User
Hello nunkaboy - and welcome to the forum.

Have a read through My First Application; this will show you how to create a form and put some controls on it. You will probably need a couple of TextBoxes for your inputs, then a Label or TextBox for the resulting BMI.

Good Luck :)
 

mjcoon

Well-Known Member
Licensed User
When you have followed Zenerdiode's advice and got your basic calculation working you will be able to move to the next level. (Or may already have fallen into a trap...)

I think BMI involves a division calculation. If the divisor is zero then the result is infinity and this typically gives computer CPU's a bad headache. Thus the "next level" involves checking the user's typed input to ensure that the result should be a sensible answer.

Mike.
 

nunkaboy

Member
Still Exploding

Hi i,ve got the form running but need a hand with the formatting when i try and use maths operators on my input text i get errors saying in put string in wrong format , so my prob is i cant even get to inputs to add together

Told you i was a ne w newbie
Thanks for help so far
 

nunkaboy

Member
Heres Hoping

Hi i,ve attached my code i know the calc is right but its the formay i,m really unsure of]
all i want this to do is work out total inches and total pounds and then divide them i cant even do this HELP
 

nunkaboy

Member
Heres Hoping

Hi i,ve attached my code i know the calc is right but its the formay i,m really unsure of]
all i want this to do is work out total inches and total pounds and then divide them i cant even do this HELP

Regards In Ignorance

Thanks
 

Attachments

  • bmicalc.sbp
    1.5 KB · Views: 195

mjcoon

Well-Known Member
Licensed User
... i get errors saying in put string in wrong format , so my prob is i cant even get to inputs to add together

Running your code under "Debug" allows you to look at the value of, for instance, "inches.text" and what it says is "Inches". This is not a number, hence the error message. I think this is merely because it should have been "ins.text" (which is the name of the textbox rather than its accompanying label).

You are almost there!

In general, it may help to incorporate the type of the control with its name. If you had called them "labInches" and "textInches" then you might not have chosen the wrong one.

I could have said, in my earlier message about (not) dividing by zero, that it can also be helpful to check if the entered string is numeric (using IsNumeric(), for example) before putting it in a calculation.

HTH, Mike.
 

mjcoon

Well-Known Member
Licensed User
Hi i,ve attached my code i know the calc is right but its the formay i,m really unsure of]

It's always dangerous to say "i know the calc is right"!

I thought that I remembered that although the BMI is not what a physicist would expect (because mass should be proportional to the cube of a dimension), it requires a square.

From Body mass index - Wikipedia, the free encyclopedia:

Body mass index is defined as the individual's body weight divided by the square of his or her height.​

Your code does not have the squaring: it should be
B4X:
totlbs/(totins ^2)

But, looking further at Wikipedia, there are multipliers depending on what units the weight and height are measured in, I suppose so that the resulting numbers compare. For pounds and inches it says this should be:
B4X:
totlbs * 703/(totins ^2)

Remember, programmers are geeks first and foremost!

Mike.
 
Top