Negative sign appears after number

In the enclosed file the display of all negative numbers occurs with the negative sign appearing after the number. Why is that the default. For example, instead of displaying -52%, this number is displayed as 52%-. The code to display is:

PercentCostVariance.Text = FormatPercent((ActualCosts - OriginalCosts) / OriginalCosts, 1)

I have checked my default window settings for Negative number format: -1.1
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sounds like it may be using regional settings---where the - comes after

See this page:
You can also force the format so that the display is consistent for all users thoughout your deployment and not dependent on any windows settings:
PercentCostVariance.Text = FormatPercent((ActualCosts - OriginalCosts) / OriginalCosts, 1).ToString("-%0.00")
The format here also forces 2 decimal places for precision.
labtracAuthor Commented:
When I tried the solution,

PercentCostVariance.Text = FormatPercent((ActualCosts - OriginalCosts) / OriginalCosts, 1).ToString("-%0.00")

 I got the following runtime error: InvalidCastException

Unable to cast object of type 'System.String' to type 'System.IFormatProvider'.
Active Protection takes the fight to cryptojacking

While there were several headline-grabbing ransomware attacks during in 2017, another big threat started appearing at the same time that didn’t get the same coverage – illicit cryptomining.

labtracAuthor Commented:
The only solution I found was the following, but this solution is not acceptable as it puts parentheses around the negative number and I want a - sign:

PercentCostVariance.Text = FormatPercent((ActualCosts - OriginalCosts) / OriginalCosts, NumDigitsAfterDecimal:=1, UseParensForNegativeNumbers:=True)
labtracAuthor Commented:
I figured out what is going on here. There is a right to left property for this field. When set to No it displays the number correctly as -28.7%, but left justified in the textbox. I was trying to get it displayed right justified in the textbox and I thought that setting the right to left property to Yes would do that. It does, but has the unintended consequence of putting the - sign after the % sign. So now I need another way of right justified the text in a texbox
If it is a standard windows forms textbox, you should be able to use the TextAlign property.
(sorry for my earlier submission that steered you in the wrong direction - I should have tested it before posting.)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
labtracAuthor Commented:
Thanks that works. I also have a ListBox. There does not appear to be a way to apply this property to this type of object.
There isn't any native justification in a listbox - what I've had to do in the past is set the font to a fixed font (courier new or lucida console or some other such font) and then use padleft so that everything aligns to the right.
With a fixed font, the 6 will line up under the 4.
Hope this helps.
labtracAuthor Commented:
Thanks, ugly solution, but it works! Wish there was a way to not have to change the font.
I agree - if anyone else has another solution, please post it because I'd like to see it.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.