开发者

Format two decimal places in VB.NET

开发者 https://www.devze.com 2023-03-24 03:56 出处:网络
I want to format a number, e.g. 279388242. Output: 2,793,882.42 How c开发者_如何学JAVAan I do this?Try this:

I want to format a number, e.g. 279388242.

Output: 2,793,882.42

How c开发者_如何学JAVAan I do this?


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.


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))


Dim myNumber As Integer = 279388242

Dim myResult As String = FormatNumber(myNumber / 100, 2,,, TriState.True)

MsgBox(myResult)
0

精彩评论

暂无评论...
验证码 换一张
取 消