metropia
asked on
ASP - Converting Inches to Feet with Inches
I would like to get some help working out a formula to obtain the feet - inch value based on a inch value.
Example:
If I have a value of 244 inches
I would like to convert it to 20 feet .333 inches (rounding up/ down the inches value would be great)
and then save each calculated value to a separate record set field like:
rsData("BoxLength_Feet") = 20
rsData("BoxLength_Inch") = .333
I hope this is not much trouble but I really need the help.
Thank you very much.
Example:
If I have a value of 244 inches
I would like to convert it to 20 feet .333 inches (rounding up/ down the inches value would be great)
and then save each calculated value to a separate record set field like:
rsData("BoxLength_Feet") = 20
rsData("BoxLength_Inch") = .333
I hope this is not much trouble but I really need the help.
Thank you very much.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
hi strickdd,
let me give that a try.
thanks!
let me give that a try.
thanks!
ASKER
i see it works partially.
the only problem so far i have seen is that if i have a value of 11 inches
then i get this on each field:
rsData("BoxLength_Feet") = 1
rsData("BoxLength_Inch") = 11
that is wrong, right?
in this case 11 inch = 0.916 feet
so the values in this case should be:
rsData("BoxLength_Feet") = 0
rsData("BoxLength_Inch") = 11
there is another example
when the inches are 18
rsData("BoxLength_Feet") = 2
rsData("BoxLength_Inch") = 6
i think 18 inches = 1 feet .5 inches
this is how i implemented the code:
these 3 variables contain the original inches values for the calculation.
BoxLength
BoxWidth
BoxHeight
rsData("BoxLength_Feet") = cint(trim(request.form("Bo xLength")) /12)
rsData("BoxLength_Inch") = cint(trim(request.form("Bo xLength")) MOD 12)
rsData("BoxWidth_Feet") = cint(trim(request.form("Bo xWidth"))/ 12)
rsData("BoxWidth_Inch") = cint(trim(request.form("Bo xWidth")) MOD 12)
rsData("BoxHeight_Feet") = cint(trim(request.form("Bo xHeight")) /12)
rsData("BoxHeight_Inch") =cint(trim(request.form("B oxHeight") ) MOD 12)
Thank you for your help.
the only problem so far i have seen is that if i have a value of 11 inches
then i get this on each field:
rsData("BoxLength_Feet") = 1
rsData("BoxLength_Inch") = 11
that is wrong, right?
in this case 11 inch = 0.916 feet
so the values in this case should be:
rsData("BoxLength_Feet") = 0
rsData("BoxLength_Inch") = 11
there is another example
when the inches are 18
rsData("BoxLength_Feet") = 2
rsData("BoxLength_Inch") = 6
i think 18 inches = 1 feet .5 inches
this is how i implemented the code:
these 3 variables contain the original inches values for the calculation.
BoxLength
BoxWidth
BoxHeight
rsData("BoxLength_Feet") = cint(trim(request.form("Bo
rsData("BoxLength_Inch") = cint(trim(request.form("Bo
rsData("BoxWidth_Feet") = cint(trim(request.form("Bo
rsData("BoxWidth_Inch") = cint(trim(request.form("Bo
rsData("BoxHeight_Feet") = cint(trim(request.form("Bo
rsData("BoxHeight_Inch") =cint(trim(request.form("B
Thank you for your help.
Try this, haven't tested it here.
rsData("BoxLength_Feet") = int(cint(trim(request.form ("BoxLengt h")))/12)
rsData("BoxLength_Inch") = cint(trim(request.form("Bo xLength")) ) MOD 12
~bp
rsData("BoxLength_Feet") = int(cint(trim(request.form
rsData("BoxLength_Inch") = cint(trim(request.form("Bo
~bp
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
billprew:
if working witht the following test values:
BoxLength = 244 in
BoxWidth = 21 in
BoxHeight = 15 in
after applying your calculation:
rsData("BoxLength_Feet") = cint(trim(request.form("Bo xLength")) /12)
rsData("BoxLength_Inch") = cint(trim(request.form("Bo xLength")) MOD 12)
rsData("BoxWidth_Feet") = int(cint(trim(request.form ("BoxWidth ")))/12)
rsData("BoxWidth_Inch") = cint(trim(request.form("Bo xWidth"))) MOD 12
rsData("BoxHeight_Feet") = int(cint(trim(request.form ("BoxHeigh t")))/12)
rsData("BoxHeight_Inch") = cint(trim(request.form("Bo xHeight")) ) MOD 12
Results:
BoxLength_Feet = 20
BoxLength_Inch = 4
BoxWidth_Feet = 1
BoxWidth_Inch = 9
BoxHeight_Feet = 1
BoxHeight_Inch = 3
It looks much better and accurate, but I still have a doubt.
the converter on this page:
http://www.onlineconversion.com/length_common.htm
tells me that an inch value of 21 should be equal to 1.75 feet and an inch value of 15 shoud be 1.25 feet.
why the calculation leave respectively me with
(21 inches)
BoxWidth_Feet = 1
BoxWidth_Inch = 9
(15)
BoxHeight_Feet = 1
BoxHeight_Inch = 3
I am not complaining at all. I appreciate your help. I just want to know why the differences.
Thank you so much.
if working witht the following test values:
BoxLength = 244 in
BoxWidth = 21 in
BoxHeight = 15 in
after applying your calculation:
rsData("BoxLength_Feet") = cint(trim(request.form("Bo
rsData("BoxLength_Inch") = cint(trim(request.form("Bo
rsData("BoxWidth_Feet") = int(cint(trim(request.form
rsData("BoxWidth_Inch") = cint(trim(request.form("Bo
rsData("BoxHeight_Feet") = int(cint(trim(request.form
rsData("BoxHeight_Inch") = cint(trim(request.form("Bo
Results:
BoxLength_Feet = 20
BoxLength_Inch = 4
BoxWidth_Feet = 1
BoxWidth_Inch = 9
BoxHeight_Feet = 1
BoxHeight_Inch = 3
It looks much better and accurate, but I still have a doubt.
the converter on this page:
http://www.onlineconversion.com/length_common.htm
tells me that an inch value of 21 should be equal to 1.75 feet and an inch value of 15 shoud be 1.25 feet.
why the calculation leave respectively me with
(21 inches)
BoxWidth_Feet = 1
BoxWidth_Inch = 9
(15)
BoxHeight_Feet = 1
BoxHeight_Inch = 3
I am not complaining at all. I appreciate your help. I just want to know why the differences.
Thank you so much.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you for the explanation. I apologize for my ignorance.
No need to apologize, there are no bad questions, hope that helped.
~bp
~bp
ASKER
Thank you both of you guys.
I tried my best to split the points fairly.
I ended up using bill's solution, but did not want to omit strickdd's recommendation either.
Best regards.
I tried my best to split the points fairly.
I ended up using bill's solution, but did not want to omit strickdd's recommendation either.
Best regards.
Welcome.
~bp
~bp
ASKER
string feet = int.parse(44/12).ToString(
string inches = int.parse(44%12).ToString(
but I think that is using vb.net or C# and I am using classic asp with vbscript. Maybe I could get help converting the code to this version of ASP?
Thank again!