James123
James123

Reputation: 11652

string format for numbers or currency?

I need to give comma(,) for every thousends. So I used DataFormatString="${0:#,#}". It is working fine. But when value is 0. It is showing $00. I just want to show only $0.

How can we do that?

Upvotes: 17

Views: 64431

Answers (2)

Dismissile
Dismissile

Reputation: 33071

DataFormatString = "{0:C0}"

That will format as a currency with 0 decimal places.

DataFormatString = "{0:N0}"

This will format as a number such as 1,000. If you want decimal places then replace the second 0 with however many numbers you want after the decimal.

For example:

DataFormatString = "{0:N4}"

Would format like 1,000.0000

Upvotes: 41

The Smallest
The Smallest

Reputation: 5783

Format = "${0:#,0}";

Upvotes: 8

Related Questions