469,299 Members | 2,069 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,299 developers. It's quick & easy.

Convert ounces to pounds and ounces

I have an invoice that lists the various products' weights in ounces. My client would then like to total those amounts (no big deal), but then post the total amount in the format of "X Lbs and Y Oz".
Can anyone come up with a means of deriving such text items? By the way, he would like to reflect the ounces to the first decimal point (each of the items carries their weight to a single digit).
Thanks for the assistance.
Sep 23 '10 #1

✓ answered by OldBirdman

I know there are 16 Avoirdupois ounces in a pound, 12 Troy ounces.
A condition here is "By the way, he would like to reflect the ounces to the first decimal point (each of the items carries their weight to a single digit)." So we have partial ounces.
Expand|Select|Wrap|Line Numbers
  1. oz = 42.7
  2. lb = Int(oz / 16)  'Use 12 if Troy ounces
  3. oz = oz - (lb * 16) 'Mod Function returns an integer     'Use 12 if Troy ounces
  4. answer = lb & " Lbs and " & Format(oz,"0.0") & " Oz"  'To ALWAYS show Oz to 1 decimal place, even if whole number
  5. '2 Lbs and 10.7 Oz

4 6714
Mariostg
332 100+
Knowing there are 16 ounces in a pound:
Expand|Select|Wrap|Line Numbers
  1. oz = 8
  2. lb = Int(oz / 16)
  3. oz = oz Mod 16
  4. answer = lb & " lbs and " & oz & " ounces"
  5.  
Sample above returns answer = 0 lbs and 8 ounces
Sep 24 '10 #2
OldBirdman
675 512MB
I know there are 16 Avoirdupois ounces in a pound, 12 Troy ounces.
A condition here is "By the way, he would like to reflect the ounces to the first decimal point (each of the items carries their weight to a single digit)." So we have partial ounces.
Expand|Select|Wrap|Line Numbers
  1. oz = 42.7
  2. lb = Int(oz / 16)  'Use 12 if Troy ounces
  3. oz = oz - (lb * 16) 'Mod Function returns an integer     'Use 12 if Troy ounces
  4. answer = lb & " Lbs and " & Format(oz,"0.0") & " Oz"  'To ALWAYS show Oz to 1 decimal place, even if whole number
  5. '2 Lbs and 10.7 Oz
Sep 24 '10 #3
Mariostg
332 100+
OldBirdMan, you are eagle eye but I am sure so does the OP.
Sep 24 '10 #4
That was a great solution!! For others reading this thread, I placed the three lines of code (shown as 2,3,and 4) into a query where I had the total ounces to be converted. It works perfectly.
Thanks again!!
Sep 24 '10 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Robert Zierhofer | last post: by
19 posts views Thread by Lauren Quantrell | last post: by
2 posts views Thread by Calvin | last post: by
1 post views Thread by Logan X via .NET 247 | last post: by
2 posts views Thread by Joel Moore | last post: by
3 posts views Thread by Convert TextBox.Text to Int32 Problem | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.