Options

How to put decimal places on a var

DarkHorseDarkHorse Member Posts: 389
Dear sirs, I've a code that shows a message that shows and import, this import came from the division from two fields. The code is similar to:

importvar:=(Item."import1")/(Item."import2");
MESSAGE:='You must sum '
+FORMAT(importvar)+' to the cost';

The problem is that the message shows a lot of decimals, dependes of the import, and I want that it only shows 2 decimal places. The import1 and import2 fields are decimal type and have 0 decimal places in their properties, but I don't know how to do the same on the var. Any idea please?.
Thanks in advance.

Comments

  • Options
    damirdamir Member Posts: 28
    Hi,

    You can use formatting instructions. For example, you can format your message like this:
    MESSAGE:='You must sum '
    +FORMAT(importvar, 0, '<Precision,2:2><Standard Format,0>' )+' to the cost';

    This will show only 2 decimal places.


    Damir
  • Options
    DarkHorseDarkHorse Member Posts: 389
    Fantastic!!; it works perfectly.
    Thank you very much for your help.
Sign In or Register to comment.