Visio Guy

Visio Discussions => General Visio => Topic started by: Wilhelm on April 02, 2015, 02:22:20 AM

Title: Number format - show + sign
Post by: Wilhelm on April 02, 2015, 02:22:20 AM
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!)
Title: Re: Number format - show + sign
Post by: Wilhelm on April 02, 2015, 02:52:06 AM
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

Title: Re: Number format - show + sign
Post by: Yacine on April 02, 2015, 04:49:41 AM
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
Title: Re: Number format - show + sign
Post by: Wilhelm on April 02, 2015, 04:53:37 AM
Wonderful - thank you very much, Yacine!