"+" character in a number-formatted text box

Stimulsoft Reports.NET discussion
Post Reply
Artimidor
Posts: 38
Joined: Thu Jan 09, 2020 8:15 am

"+" character in a number-formatted text box

Post by Artimidor »

Usually, when a text box has the text format "Number" and Decimal Digits 2, you get something like "13.34" as a result.

Now, if a character is put in front, the result is e.g. "A13.34" - so the format works, and the character is shown. However, if a plus-sign (+) is used instead of the character, this is eliminated whenever the number is positive (result: 13.34). If the number is negative I get "+-13.34". How is it possible to show e.g. "+13.34" and keep the text format a number? The idea would be to add a plus whenever the number is positive and if it is negative keep it as it is.
Lech Kulikowski
Posts: 6243
Joined: Tue Mar 20, 2018 5:34 am

Re: "+" character in a number-formatted text box

Post by Lech Kulikowski »

Hello,

You can use the Format function:
{String.Format("+{0:N2}",Variable1)}

Thank you.
Artimidor
Posts: 38
Joined: Thu Jan 09, 2020 8:15 am

Re: "+" character in a number-formatted text box

Post by Artimidor »

Yes, this works as intended (text format in this case has to be "General" of course). Thank you!
Lech Kulikowski
Posts: 6243
Joined: Tue Mar 20, 2018 5:34 am

Re: "+" character in a number-formatted text box

Post by Lech Kulikowski »

Hello,

You are welcome.
Post Reply