Hi
I am trying to divide a variable by 1 to get a number, but everything I have tried doesnt seem to work. Here is the code:
var a:Number=Number (R_P1.text)
var b:Number=Number (R_P2.text)
var c:Number=Number (R_P3.text)
var d:Number=Number (R_P4.text)
var e:Number=Number (R_P5.text)
var f:Number=Number (R_P6.text)
var g:Number=Number (R_P7.text)
var h:Number=Number (R_P8.text)
var i:Number=Number (R_P9.text)
var j:Number=Number (R_P10.text)
var k:Number = (1/a)+(1/b)+(1/c)+(1/d)+(1/e)+(1/f)+(1/g)+(1/h)+(1/h)+(1/j)
TotalR_P.text = String (k)
Thanks for the help!!
David
What does "doesn't seem to work" mean?
- Gordon
This returns "Infinity" regardless of the values of 'a' through 'j'.
david567890 wrote:
This returns "Infinity" regardless of the values of 'a' through 'j'.
OK, I gave your example a go.
If I leave the boxes blank and run, I get Infinity. (fair enough)
If I populate the text fields with 1 and then run I get 10. (correct answer)
If I leave any box empty I get Infinity. (fair enough)
I'm curious as to how you are allowing the user to populate the fields then call the code you have supplied. Sounds like you are running the calculation before the fields are populated.