Include decimals in string output

RoelofRoelof Member Posts: 377
I want to print a decimal value as follows:
(10.00)
I tried the following:
Amount := 10; //defined as a decimal
AmountToPrint := '(' + format(Amount,''<Sign><Integer Thousand><Decimals,2>') + ')'; //AmountToPrint is defined as text.

When I compile, it gives me an error: Type conversion is not possible. Integer := Text.

Any ideas?
Roelof de Jonghttp://www.wye.com

Comments

  • SavatageSavatage Member Posts: 7,142
    is AmounttoPrint defined as an integer.

    //comment out that line & try to compile. If you still see the error then it's not that part of the code but somewhere else.
  • ara3nara3n Member Posts: 9,256
    AmountToPrint := '(' + format(Amount,0,'<Sign><Integer Thousand><Decimals,2>') + ')';
    
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • RoelofRoelof Member Posts: 377
    Never mind. I figured it out. There should have been an integer just before the '< ...>' string, indicating the lenght of the value.
    I have it now defined as:
    AmountToPrint := format(Amount,7,'(<Sign><Integer Thousand><Decimals,2>)';

    I included the '(' and ')' in the format string.
    This works great.
    Roelof de Jonghttp://www.wye.com
Sign In or Register to comment.