的String.Format(QUOT; {0:C2}" ;, -1234)(货币格式)把负数为正
问题描述:
我使用的String.Format({0:C2},-1234)。
来格式化数字
它总是格式化量为正数,而我希望它成为$ - 1234
It always formats the amount to a positive number, while I want it to become $ - 1234
答
我想我会简单地使用:
FormatCurrency(-1234.56, 2, UseParensForNegativeNumbers:=TriState.False)
(在Microsoft.VisualBasic.Strings模块)
(in Microsoft.VisualBasic.Strings module)
或在较短的话(这是林实际上要使用):
Or in shorter words (this is what im actually going to use):
FormatCurrency(-1234.56, 2, 0, 0)
或者我会让自己使用VB的功能,通过我的自订参数自定义formatcurrency功能。
Or I will make myself a custom formatcurrency function that uses the VB function passing my custom params.
有关详细信息,看一看在的 FormatCurrency函数(Visual Basic)在MSDN。
For further details take a look at the FormatCurrency Function (Visual Basic) in the msdn.