vb.net 在VB.NET中格式化两位小数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6882252/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 15:37:58 来源:igfitidea点击:
Format two decimal places in VB.NET
提问by user870510
I want to format a number, e.g. 279388242
.
我想格式化一个数字,例如279388242
.
Output: 2,793,882.42
输出: 2,793,882.42
How can I do this?
我怎样才能做到这一点?
回答by Tim
Try this:
尝试这个:
Dim myNumber As Int = 279388242
Dim myNumberString As String = (myNumber * .01).ToString("N2") ' 2,793,882.42
I'm pretty sure there's a better way to do it, but that should get you going.
我很确定有更好的方法来做到这一点,但这应该会让你继续前进。
回答by abdellah gogop
MsgBox(11.0F / 12.0F)
MsgBox(FormatNumber(10000000D, -1, TriState.True, TriState.UseDefault, TriState.True))
MsgBox(FormatCurrency(10000000I, -1, TriState.UseDefault, TriState.UseDefault, TriState.True))