的String.Format(QUOT; {0:C2}&QUOT ;, -1234)(货币格式)把负数为正 [英] String.Format("{0:C2}", -1234) (Currency format) treats negative numbers as positive

查看:437
本文介绍了的String.Format(QUOT; {0:C2}&QUOT ;, -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.

这篇关于的String.Format(QUOT; {0:C2}&QUOT ;, -1234)(货币格式)把负数为正的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆