Number format - show + sign

Started by Wilhelm, April 02, 2015, 02:22:20 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Wilhelm

Would someone mind helping me with the following in Visio 2010, please?  I'm trying to display the '+' signs when an integer is positive.  Just can't seem to get it right!  (Apologies for what is likely to be something really silly!)

Wilhelm

I have since found a workaround by casting the value as I need it from SQL, but would still be keen to find out if anybody could help with this.  Thanks.

In case anybody was wondering, this is the SQL command I used:
    CASE WHEN [ChangeBaseline]<=0 THEN CAST(ChangeBaseline as VARCHAR(12)) ELSE '+' + CAST(ChangeBaseline as VARCHAR(12)) END AS ChangeBaseline


Yacine

Hi Wilhelm,
You can use the FORMAT function in both the shapesheet and VBA to adjust the way your variables are displayed.
For numbers the syntax is FORMAT (x, " format of positive numbers; negative numbers; zero")
To add a sign for one of these formats you can use apostrophes to include them in the format string.
ie: format( x , " '+' #; '-' #")
or a single "\" if the prefix is only one char:
format(x, "\+#;\-#")
https://msdn.microsoft.com/en-us/library/office/gg251755.aspx
Yacine

Wilhelm

Wonderful - thank you very much, Yacine!