Johnny
asked on
convert decimal hundredths to feet and inches (vb.net - 2008 - windows form)
i am working on a project that has height and its in decimal hundredths form i need it to be feet and inches
heres what i got so far
it should return 6.6 from 90 but i get
PackageDimensions.Height: 90
PackageDimensions.Height - inches: 7.50
thank you in advance for any code or help you may provide.
heres what i got so far
it should return 6.6 from 90 but i get
PackageDimensions.Height: 90
PackageDimensions.Height - inches: 7.50
thank you in advance for any code or help you may provide.
Try ' read PackageDimensions.Height
Result_Box.AppendText("PackageDimensions.Height: " & item.ItemAttributes.PackageDimensions.Height.Value & vbCrLf)
Dim b_height As Decimal = Format((item.ItemAttributes.PackageDimensions.Height.Value / 12), "#.00")
Result_Box.AppendText("PackageDimensions.Height - inches: " & b_height.ToString & vbCrLf)
Catch ex As Exception
textboxauth.Text = "Error reading PackageDimensions.Height: " & ex.ToString()
End Try
If you need the formulas you have:
1 - 12
ft - inch
feet = inches / 12
inches = feet * 12
1 - 12
ft - inch
feet = inches / 12
inches = feet * 12
ASKER
Dim b_height As Decimal = FormatNumber(CStr(CDbl(((i tem.ItemAt tributes.P ackageDime nsions.Wei ght.Value) / 100) * 12)), 2)
returns
PackageDimensions.Height: 90
PackageDimensions.Height - inches: 2.40
im still not getting it right tho
im really bad at math trust me really bad
returns
PackageDimensions.Height: 90
PackageDimensions.Height - inches: 2.40
im still not getting it right tho
im really bad at math trust me really bad
Erm,
90 / 12 = 7.50
The answer you are getting is correct, and so is your code mate.
:)
90 / 12 = 7.50
The answer you are getting is correct, and so is your code mate.
:)
>it should return 6.6 from 90 but i get
Are you sure? I think you mean 7.6!
Try this code
Dim Height As Integer = 90
Dim Divider As Integer = 12
Dim Feet As Integer
Dim Inches As Integer
Feet = Math.DivRem(Height, Divider, Inches)
Debug.Print(String.Concat( Feet, ".", Inches))
Are you sure? I think you mean 7.6!
Try this code
Dim Height As Integer = 90
Dim Divider As Integer = 12
Dim Feet As Integer
Dim Inches As Integer
Feet = Math.DivRem(Height, Divider, Inches)
Debug.Print(String.Concat(
Aaaah!
You want it displayed as 7 feet 6 inches, not 7.5 feet!
Try this code formula :
You want it displayed as 7 feet 6 inches, not 7.5 feet!
Try this code formula :
numbervar inches :=90;
ToText(int(inches/12),0,"" ) & "' " & totext(remainder(inches,12 ),0) & '"'
ToText(int(inches/12),0,""
>ToText(int(inches/12),0," ")
Are you sure it wont round it? 7.6->8?
Are you sure it wont round it? 7.6->8?
ASKER
hrrm somethings wrong in denmark then.. its a book im trying to do.
the book is 6 and 3/4 inches
amazon says its 6.6
Product Dimensions: 6.6 x 4.1 x 0.9 inches
im getting the data from amazon so the hundredths of a inch of 90 is from them
i hate math i got a headache.
i need to go to a Sunday engagement ill be back in a few hours
thanks for all the help so far
the book is 6 and 3/4 inches
amazon says its 6.6
Product Dimensions: 6.6 x 4.1 x 0.9 inches
im getting the data from amazon so the hundredths of a inch of 90 is from them
i hate math i got a headache.
i need to go to a Sunday engagement ill be back in a few hours
thanks for all the help so far
ASKER
i have the physical book too
ASKER
ill be back in a few hours
ASKER
still not right on dimensions
amazon says one thing im getting totally different info
PackageDimensions.Weight: 44
PackageDimensions.Weight-o z: 7.04oz
PackageDimensions.Height: 94
PackageDimensions.Height - inches: 7.83
PackageDimensions.Length: 772
PackageDimensions.Length - inches: 64.33
PackageDimensions.Width: 504
PackageDimensions.Width - inches: 42.00
http://www.amazon.com/Pursuit-Alice-Thrift-Elinor-Lipman/dp/0007161204%3FSubscriptionId%3DAKIAJMR3IOWLNS3J7BKQ%26tag%3Dws%26linkCode%3Dsp1%26camp%3D2025%26creative%3D165953%26creativeASIN%3D0007161204
amazon says one thing im getting totally different info
PackageDimensions.Weight: 44
PackageDimensions.Weight-o
PackageDimensions.Height: 94
PackageDimensions.Height - inches: 7.83
PackageDimensions.Length: 772
PackageDimensions.Length - inches: 64.33
PackageDimensions.Width: 504
PackageDimensions.Width - inches: 42.00
http://www.amazon.com/Pursuit-Alice-Thrift-Elinor-Lipman/dp/0007161204%3FSubscriptionId%3DAKIAJMR3IOWLNS3J7BKQ%26tag%3Dws%26linkCode%3Dsp1%26camp%3D2025%26creative%3D165953%26creativeASIN%3D0007161204
Try ' read PackageDimensions.Height
Result_Box.AppendText("PackageDimensions.Height: " & item.ItemAttributes.PackageDimensions.Height.Value & vbCrLf)
Dim b_height As Decimal = FormatNumber(CStr(CDbl(((item.ItemAttributes.PackageDimensions.Height.Value) / 12))), 2)
Result_Box.AppendText("PackageDimensions.Height - inches: " & b_height.ToString & vbCrLf)
Catch ex As Exception
textboxauth.Text = "Error reading PackageDimensions.Height: " & ex.ToString()
End Try
Try ' read PackageDimensions.Length
Result_Box.AppendText("PackageDimensions.Length: " & item.ItemAttributes.PackageDimensions.Length.Value & vbCrLf)
Dim b_Length As Decimal = FormatNumber(CStr(CDbl(((item.ItemAttributes.PackageDimensions.Length.Value) / 12))), 2)
Result_Box.AppendText("PackageDimensions.Length - inches: " & b_Length.ToString & vbCrLf)
Catch ex As Exception
textboxauth.Text = "Error reading PackageDimensions.Length: " & ex.ToString()
End Try
Try ' read PackageDimensions.Width
Result_Box.AppendText("PackageDimensions.Width: " & item.ItemAttributes.PackageDimensions.Width.Value & vbCrLf)
Dim b_Width As Decimal = FormatNumber(CStr(CDbl(((item.ItemAttributes.PackageDimensions.Width.Value) / 12))), 2)
Result_Box.AppendText("PackageDimensions.Width - inches: " & b_Width.ToString & vbCrLf)
Catch ex As Exception
textboxauth.Text = "Error reading PackageDimensions.Width: " & ex.ToString()
End Try
I wouldl think that amazon is just dividing the inches by 12 so that 90 is 7.5 feet. Feet and inches are not separated by dot. Feet and dots are represented differently. Similarly for times, 90 mintues is 1.5 hours!
ASKER
if you look at the links its a paperback book... ever see a paperback book at 7.5 feeet???
somethings wrong with the calc. there are two books links both cant be that far off.
this is why im asking for help i couldn't figure it out
somethings wrong with the calc. there are two books links both cant be that far off.
this is why im asking for help i couldn't figure it out
What do you think 94 is then? It would be cm probably.
ASKER
this is the link to the book
http://www.amazon.com/Safety-Incentives-Recognition-Programs-Compliance/dp/1890966533/ref=sr_1_1?ie=UTF8&qid=1269883064&sr=8-1
amazon returns this in xml format
Wayne G. Pardy
Paperback
9781890966539
Reprint
1890966533
5995
USD
$59.95
185
900
75
130
600
Book
1999-05-19
Safetycertified.Com Inc
Safety Incentives: The Pros and Cons of Award and Recognition
Programs (Osha Compliance)
we are trying to convert this area
900
75
130
600
this is what amazons page says about book dimensions
Product Dimensions: 9 x 6 x 0.8 inches
Shipping Weight: 1.3 pounds
so if we do our calc it should be in fact
9 inches high
7.5 inches wide
6 inches thick
man thats a hefty paperback book
somethings wrong here dunno what
http://www.amazon.com/Safety-Incentives-Recognition-Programs-Compliance/dp/1890966533/ref=sr_1_1?ie=UTF8&qid=1269883064&sr=8-1
amazon returns this in xml format
Wayne G. Pardy
Paperback
9781890966539
Reprint
1890966533
5995
USD
$59.95
185
900
75
130
600
Book
1999-05-19
Safetycertified.Com Inc
Safety Incentives: The Pros and Cons of Award and Recognition
Programs (Osha Compliance)
we are trying to convert this area
900
75
130
600
this is what amazons page says about book dimensions
Product Dimensions: 9 x 6 x 0.8 inches
Shipping Weight: 1.3 pounds
so if we do our calc it should be in fact
9 inches high
7.5 inches wide
6 inches thick
man thats a hefty paperback book
somethings wrong here dunno what
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
so all i do is divide by 100 and round to .#
???
FormatNumber(CStr(CDbl(((i tem.ItemAt tributes.P ackageDime nsions.Len gth.Value) / 100))), 2)
???
FormatNumber(CStr(CDbl(((i
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>130 hundreds of inches = 1.3 inches (weight)
Never knew weight is expressed in inches as well.
We are confused why thickness is being referred to as length.
Never knew weight is expressed in inches as well.
We are confused why thickness is being referred to as length.
ASKER
yeah there fields are messed up
PackageDimensions.Weight: 130
PackageDimensions.Weight-o z: 20.80oz
PackageDimensions.Weight-l bs: 1.30lbs
PackageDimensions.Height: 75
PackageDimensions.Height - inches: 0.75
PackageDimensions.Length: 900
PackageDimensions.Length - inches: 9.00
PackageDimensions.Width: 600
PackageDimensions.Width - inches: 6.00
Product Dimensions: 9 x 6 x 0.8 inches
Shipping Weight: 1.3 pounds
i can live with the rounding of thick (not sure how to do that right now in vb.net(will look it up)
i get it
length = tall
width = wide
height = thick
PackageDimensions.Weight: 130
PackageDimensions.Weight-o
PackageDimensions.Weight-l
PackageDimensions.Height: 75
PackageDimensions.Height - inches: 0.75
PackageDimensions.Length: 900
PackageDimensions.Length - inches: 9.00
PackageDimensions.Width: 600
PackageDimensions.Width - inches: 6.00
Product Dimensions: 9 x 6 x 0.8 inches
Shipping Weight: 1.3 pounds
i can live with the rounding of thick (not sure how to do that right now in vb.net(will look it up)
i get it
length = tall
width = wide
height = thick
>not sure how to do that right now in vb.net
For rounding, use the Math.Round function
Match.Round(0.75, 1)
For rounding, use the Math.Round function
Match.Round(0.75, 1)
For roundings use the System.Math.Round
http://msdn.microsoft.com/en-us/library/zy06z30k.aspx
http://msdn.microsoft.com/en-us/library/zy06z30k.aspx
ASKER
ok now who the heck answered this..
400 points - ID: 29002645 CodeCruiser: for the /100
100 points - AlexCode: for pointing out im dumb and had it all along, and the reason for the fields being the way they are
sound about right? (i like to be fair)
400 points - ID: 29002645 CodeCruiser: for the /100
100 points - AlexCode: for pointing out im dumb and had it all along, and the reason for the fields being the way they are
sound about right? (i like to be fair)
I am ok with it.
fair mate... the important is you getting it right! :)
cheers!
cheers!
ASKER
PackageDimensions.Weight: 130
PackageDimensions.Weight-o z: 20.80oz
PackageDimensions.Weight-l bs: 1.30lbs
PackageDimensions.Height: 75
PackageDimensions.Height - inches: 0.8
PackageDimensions.Length: 900
PackageDimensions.Length - inches: 9.00
PackageDimensions.Width: 600
PackageDimensions.Width - inches: 6.00
one last thing please how do i get the 9.00 and 6.00 to be a whole number but show .# if needed ie
9.0 = 9
and 9.3 = 9.3?
NO 0 on 9.0 if its got one?
I know this is a different question but then i got this all wrapped up unless u all really want me to ask another question
and thx on the solution and the post points award too
PackageDimensions.Weight-o
PackageDimensions.Weight-l
PackageDimensions.Height: 75
PackageDimensions.Height - inches: 0.8
PackageDimensions.Length: 900
PackageDimensions.Length - inches: 9.00
PackageDimensions.Width: 600
PackageDimensions.Width - inches: 6.00
one last thing please how do i get the 9.00 and 6.00 to be a whole number but show .# if needed ie
9.0 = 9
and 9.3 = 9.3?
NO 0 on 9.0 if its got one?
I know this is a different question but then i got this all wrapped up unless u all really want me to ask another question
and thx on the solution and the post points award too
You would have to use multiple variables to hold the value. How would you use this? Would you be just showing the value on UI?
ASKER
thanks for hanging in there trying to figure this out
ASKER
im gonna open a new question for this brb with the link
Try formating the value as:
.ToString("0.##")
.ToString("0.##")
ASKER
that did it
alexcode
PackageDimensions.Weight: 130
PackageDimensions.Weight-o z: 20.80oz
PackageDimensions.Weight-l bs: 1.30lbs
PackageDimensions.Height: 75
PackageDimensions.Height - inches: 0.8
PackageDimensions.Length: 900
PackageDimensions.Length - inches: 9
PackageDimensions.Width: 600
PackageDimensions.Width - inches: 6
go post on other question ill award the points thanks again
alexcode
PackageDimensions.Weight: 130
PackageDimensions.Weight-o
PackageDimensions.Weight-l
PackageDimensions.Height: 75
PackageDimensions.Height - inches: 0.8
PackageDimensions.Length: 900
PackageDimensions.Length - inches: 9
PackageDimensions.Width: 600
PackageDimensions.Width - inches: 6
go post on other question ill award the points thanks again
https://www.experts-exchange.com/questions/25573307/convert-Hundredths-of-a-Pound-to-oz-pounds-oz-vb-net-2008-windows-form.html?cid=1131&anchorAnswerId=28895571#a28895571
but the convertion now is:
1 foot = 12 inches