Page 1 of 1

Currency Format

Posted: Wed Dec 07, 2016 6:40 am
by jyoung
How do I display a signed(15,4) field in a currency format i.e $1,505.25?

Re: Currency Format

Posted: Wed Dec 07, 2016 10:30 am
by Stewart Marshall
The next EPC will have support Edit Word support.

This allows formatting to be applied to field when it is not in focus.

An edit word similar to

Code: Select all

'  ,   ,   ,  $0.    '
will format the number. You may need to move it to a field with the appropriate number of decimal places.

Regards

Re: Currency Format

Posted: Thu Dec 08, 2016 2:23 am
by jyoung
Good to know.

Until then I got it work by defining the fields with the right number of decimals

Code: Select all

define field(#HoursWorked) type(*SIGNED) length(15) decimals(2)
define field(#GrossBillings) type(*SIGNED) length(15) decimals(2)
define field(#GrossMargin) type(*SIGNED) length(15) decimals(2)
Then when the data is returned from the ServerModule

Code: Select all

#HoursWorked := #WSHRW.Round( HalfDown 2 )
#GrossBillings := #WSBG.Round( HalfDown 2 )
#GrossMargin := #WSGMA.Round( HalfDown 2 )

#HoursWorkedLabel.Caption := #HoursWorked.AsDisplayString( EditCode_N )
#GrossBillingsLabel.Caption := "$" + #GrossBillings.AsDisplayString( EditCode_N )
#GrossMarginLabel.Caption := "$" + #GrossMargin.AsDisplayString( EditCode_N )

Re: Currency Format

Posted: Thu Dec 08, 2016 8:30 am
by Stewart Marshall
Not that I care about a few keystrokes here or there, but there's no need to specify .Caption when populating a label.

The Caption property is the default property, so this will produce the same result.

Code: Select all

#HoursWorkedLabel := #HoursWorked.AsDisplayString( EditCode_N )
Similarly, spin edit and edit have a default property of Value.

Regards

Re: Currency Format

Posted: Fri Dec 09, 2016 11:54 pm
by moon.gallop
Thanks for sharing the code.