试图编写代码,将数字123.456显示为Money

时间:2013-09-17 17:51:19

标签: vb.net visual-studio-2010

不确定这是否正确并且会给我所需的结果。

Dim d As Decimal = 123.456D
Dim s As String = d.ToString()

2 个答案:

答案 0 :(得分:4)

String.FormatC(货币)格式说明符一起使用:

Dim d As Decimal = 123.456D
Dim s as String = String.Format("{0:C}", d)

这会将您的小数转换为货币字符串,其格式由客户的区域设置指定。

答案 1 :(得分:1)

Dim d As Decimal = 123.456D
Dim s As String = d.ToString("C");