I am writing some code in Visual Basic.net and have a question.
If I have a long number, that is larger than 1000, how can I format this value to be 1,000 (with a comma) and for this to be stored in a string?
For e.g.
1234 will be stored as 1,234 12345 will be stored as 12,345 123456 will be stored as 123,456
Is this done with a TryParse statement?
May I have some help to so this?
Using
$
notation:Take a look at The Numeric ("N") Format Specifier
General use:
If you are only using integers then the following:
Will show
numberString = "1,234"
as the"N0"
format will not add any figures after a decimal point.For those wanting to do a currency with commas and decimals use the following: .ToString("$0,00.00")