I have a textbox with "10000" i want to format it to "10,000.00". How i can make it in vb.net ..

Recommended Answers

All 7 Replies

Dim n As Integer = 10000
        TextBox1.Text = n.ToString("##,##,###.00")

you provide the code but not the way I want. i want 10,000.00 not 10.000,00

this is your code :

Dim amount As Integer = CType(txtSehari.Text, Integer)

        txtSehari.Text = amount.ToString("##,##,###.00")

hmm how about this?

Dim floating As Double = 10761.937554
 TextBox1.Text = floating.ToString("N02")

seems more dynamic in case you have just 1000 or 1000000

I would use the format string "N2" as well but that will display 10,000.00 or 10.000,00 depending on your locale settings. I think you will have to follow adatapost's suggestion in order to display data in that format regardless of locale settings on the machine

yeah.. You right.. But i want to 10,000.00.. How can make it.. Not depending where i place.. Please.... I stuck ...

ok its might be not the sexiest solution ever but does the trick since we set the cultureinfo. so the users operating system should be irrelevant.

Dim floating As Double = 10761.937554
 TextBox1.Text =floating.ToString("C", New System.Globalization.CultureInfo("en-us")).Remove(0, 1)

.Remove(0, 1) removes just the dollar sign in front
prints: 10,761.94

yeah.. You right.. But i want to 10,000.00.. How can make it.. Not depending where i place.. Please.... I stuck ...

Unless I did not miss something, I found adatapost answer is what you want

Dim n As Integer = 12345
TextBox1.Text = n.ToString("###,###.00")
MsgBox("Next")
Dim d As Double = 123456.123
TextBox1.Text = d.ToString("###,###.00")
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.