A1 Letter Coding: Addition with Decimals

Closed Forum - older posts now retired. This forum is read only. You can search and view posts in this forum but you cannot reply or create new posts in this forum.
Post Reply
LMSSC
Posts: 408
Joined: Sun Jun 04, 2006 5:46 pm

A1 Letter Coding: Addition with Decimals

#1

Post by LMSSC » Tue Jan 16, 2007 6:47 pm

Dear Michael,

I please need your help with a coding problem.
Everything is good in here...

>>
Mileage incurred prior to 1/1/2007:>, Subtotal: $>
Mileage incurred on or after 1/1/2007:>, Subtotal: $>

---Up to this point---

>Mileage Total: $>

I want dollar values with cents ($XX.YY) for Memory 54, 55, & 59.

Memory 54 works & looks correct. Memory 55 works & looks correct.

In the last addition line of code the final value (59) gets rounded off rather than extending to 2 decimal points as a dollar value.

For example...

Mileage incurred prior to 1/1/2007:10, Subtotal: $4.45
Mileage incurred on or after 1/1/2007:20, Subtotal: $9.70
Mileage Total: $14 (<-- Should have been $14.15)

Any suggestions would be appreciated!

Thanks!

Sincerely,
Michael Lerner
Network Administrator
Lerner, Moore, Silva, Cunningham & Rubel
www.injuryatwork.com
(909) 889-1131
Sincerely,
Michael Lerner
Network Administrator
Lerner, Moore, Silva, Cunningham & Rubel
www.injuryatwork.com
(909) 889-1131

Anonymous User

Re: A1 Letter Coding: Addition with Decimals

#2

Post by Anonymous User » Tue Jan 16, 2007 10:42 pm

Michael - you have not specified any parameters for your STR function which is why it is getting "rounded off" whereas in the others you are specifying. For example in the first part of your code which works you have:

str(val(thisform.aStorage(46)) * .445,9, 2)

you have specified to include a total of 9 characters (including the decimal point of which 2 will be to the right of the decimal point.

Therefore you would need to make a minor change

from this:

>

to this:

>

Note: the largest number this will accommodate would be 999999.99 (which is a total of 9 characters including the decimal point). If you need to allow for a value in the millions then change it to 10,2 instead of 9,2 which would accommodate a number a penny less than 10 million.

Also, if you need to do "alignment" of the numbers then do not include the alltrim. For example:

with the alltrim to remove spaces you might have:

123.45
12.33
1.59

without the alltrim you might have:
123.45
12.33
1.59

Mike

LMSSC
Posts: 408
Joined: Sun Jun 04, 2006 5:46 pm

Re: A1 Letter Coding: Addition with Decimals

#3

Post by LMSSC » Wed Jan 17, 2007 1:33 pm

Dear Michael,

Thank you very much! The change worked as listed!

Sincerely,
Michael Lerner
Network Administrator
LMSCR
Sincerely,
Michael Lerner
Network Administrator
Lerner, Moore, Silva, Cunningham & Rubel
www.injuryatwork.com
(909) 889-1131

Post Reply