Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 8264 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies
Posted

riddle me this...I've got a 3 price fields for my products which are sold in 3 different size packages. When I calculate these prices into one text field, I'm losing all of the currency formatting of .00. for example:

small $1.00

medium $2.00

large $3.00

my calc'd field is resulting in: small $l, medium $2, large $3.

what I want to have is: small $1.00, medium $2.00, large $3.00.

thanks in advance,

Roger

  • Newbies
Posted

** The original fields are number fields are they? -- Vaughan Bromfield, Sydney, Australia **

Yes.

Roger

[ April 03, 2002, 04:48 PM: Message edited by: graphex ]

Posted

Try this calc:

"Small"&" "&"$"&NumToText(Int(Small))&

Case(Mod(Small,1)=0,".00",

Mod(Small,1) > 0 and Length(NumToText(Mod(Small,1)))=2,NumToText(Mod(Small,1))&"0",

Mod(Small,1) > 0 and Length(NumToText(Mod(Small,1)))=3,NumToText(Mod(Small,1)))&", "&

"Medium"&" "&"$"&NumToText(Int(Medium))&

Case(Mod(Medium,1)=0,".00",

Mod(Medium,1) > 0 and Length(NumToText(Mod(Medium,1)))=2,NumToText(Mod(Medium,1))&"0",

Mod(Medium,1) > 0 and Length(NumToText(Mod(Medium,1)))=3,NumToText(Mod(Medium,1)))&", "&

"Large"&" "&"$"&NumToText(Int(Large)&

Case(Mod(Large,1)=0,".00",

Mod(Large,1) > 0 and Length(NumToText(Mod(Large,1)))=2,NumToText(Mod(Large,1))&"0",

Mod(Large,1) > 0 and Length(NumToText(Mod(Large,1)))=3,NumToText(Mod(Large,1))))

Hope this helps

Posted

Here's a slightly "cleaner" calc:

"small $" & Left(NumToText(smallAmt + .001), Length(NumToText(smallAmt + .001)) - 1) &

"medium $" & Left(NumToText(medAmt + .001), Length(NumToText(medAmt + .001)) - 1) &

"large $" & Left(NumToText(largeAmt + .001), Length(NumToText(largeAmt + .001)) - 1)

The way it works is, we add .001 to the numbers to ensure they have decimal digits, then we lop off that trailing "1" by first changing the number to text, then selecting only what is to the left of that trailing 1, that is, the length minus one.

Posted

code:


CURRENCYSIGN & " " &

Case( NUMBER < 0 , "-")

&

Choose( Abs( Round( NUMBER , PRECISION )) < 10^9 ,

Right( Abs(Int( Round( NUMBER , PRECISION ) / 10^9 )) , 3 ) & "," )

&

Choose( Abs( Round( NUMBER , PRECISION )) < 10^6 ,

Right( Abs(Int( Round( NUMBER , PRECISION ) / 10^6 )) , 3 ) & "," )

&

Choose( Abs( Round( NUMBER , PRECISION )) < 10^3 ,

Right( Abs(Int( Round( NUMBER , PRECISION ) / 10^3 )) , 3 ) & "," )

&

Right( Abs( Int( Round( NUMBER , PRECISION ))) , 3 )

&

Choose( PRECISION = 0 , "." &

Right( 10^PRECISION & Abs( Round( NUMBER , PRECISION ) )

* ( 10^PRECISION ) , PRECISION ))

Where in uppercase are variables.

This one would deal with decimal virgola too.

(Result from discussion FMExperts list)

HTH

Dj

Posted

Dj, that's the second time today our posts have crossed in the mail! cool.gif But amazingly, I think my solution is better for once. ciao

Posted

Holy cow! i could not believe the LENGTH of the calculation to accomplish something that in theory should be a simple task.

Oh well, so much for my perfect world.

This topic is 8264 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.