Shimmy Shimmy - 5 years ago 355 Question

String.Format("{0:C2}", -1234) (Currency format) treats negative numbers as positive

I am using

String.Format("{0:C2}", -1234)
to format numbers.

It always formats the amount to a positive number, while I want it to become $ - 1234

Answer Source

I think I will simply use:

FormatCurrency(-1234.56, 2, UseParensForNegativeNumbers:=TriState.False)

(in Microsoft.VisualBasic.Strings module)

Or in shorter words (this is what im actually going to use):

FormatCurrency(-1234.56, 2, 0, 0)

Or I will make myself a custom formatcurrency function that uses the VB function passing my custom params.

For further details take a look at the FormatCurrency Function (Visual Basic) in the msdn.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download