G
Gordon Bentley-Mix at news.microsoft.com
I have a requirement that numbers entered into a TextBox in a UserForm be
formatting using a leading plus sign ("+") for positive numbers and minus
sign ("-") for negative numbers. In this particular instance the numbers are
meant to represent a percentage, so I'm using the FormatPercent function -
something like this:
FormatPercent(fcnExtractNumber(txtMargin.Value) / 100, 2)
where "fcnExtractNumber" is a function I've written to extract just the
numeric value from a string (because Word is absolutely crap about how it
handles formatted numbers).
This works find for negative numbers. Something like "-.5" results in
"-0.50%", as does "0.5%". (This is one instance where fcnExtractNumber comes
into play because, due to the percent sign, FormatPercent doesn't recognise
"-0.5%" as being numeric; fcnExtractNumber strips out the percent sign and
returns just "-0.5", which FormatPercent is quite happy with.)
However, I don't see any way to make FormatPercent or even the straight
Format function insert the plus sign. I'm perfectly willing to NOT use
FormatPercent if necessary - in fact, it's maybe a bit easier because I don't
have to do the whole "/ 100, 2" thing with Format - but I'm just wondering
how to specify a format with either function that includes the plus sign.
--
Cheers!
Gordon Bentley-Mix
Word MVP
Please post all follow-ups to the newsgroup.
Read the original version of this post in the Office Discussion Groups - no
membership required!
formatting using a leading plus sign ("+") for positive numbers and minus
sign ("-") for negative numbers. In this particular instance the numbers are
meant to represent a percentage, so I'm using the FormatPercent function -
something like this:
FormatPercent(fcnExtractNumber(txtMargin.Value) / 100, 2)
where "fcnExtractNumber" is a function I've written to extract just the
numeric value from a string (because Word is absolutely crap about how it
handles formatted numbers).
This works find for negative numbers. Something like "-.5" results in
"-0.50%", as does "0.5%". (This is one instance where fcnExtractNumber comes
into play because, due to the percent sign, FormatPercent doesn't recognise
"-0.5%" as being numeric; fcnExtractNumber strips out the percent sign and
returns just "-0.5", which FormatPercent is quite happy with.)
However, I don't see any way to make FormatPercent or even the straight
Format function insert the plus sign. I'm perfectly willing to NOT use
FormatPercent if necessary - in fact, it's maybe a bit easier because I don't
have to do the whole "/ 100, 2" thing with Format - but I'm just wondering
how to specify a format with either function that includes the plus sign.
--
Cheers!
Gordon Bentley-Mix
Word MVP
Please post all follow-ups to the newsgroup.
Read the original version of this post in the Office Discussion Groups - no
membership required!