-
Feb 12th, 2025, 06:04 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Comma Formatting of number with leading Zeros removed
I currently have a number that I want to display with comma's between the thousands. I have found in the documentation that I can format it using ToString("0,000,000")
if the number is 7654321, it correctly displays it as 7,654,321
However if the Number is just 4321, it display it as 0,004,321
Looking at the documentation, I can't find a formatting option to remove the leading zero's so that 4321 would be displayed as 4,321.
Without testing the length of the string and specifying a format depending upon the string length, is there a formatting option that removes the leading Zeros' ?
-
Feb 12th, 2025, 06:07 PM
#2
Re: Comma Formatting of number with leading Zeros removed
ToString("#, ##0") should do the trick
-
Feb 12th, 2025, 06:28 PM
#3
Thread Starter
Hyperactive Member
Re: Comma Formatting of number with leading Zeros removed
That's Great Thanks. Works Perfectly.
-
Feb 13th, 2025, 07:26 AM
#4
Re: [RESOLVED] Comma Formatting of number with leading Zeros removed
Try...
Code:
Dim number as decimal = 123456.00
MsgBox(number.ToString("n0")) ' = "123,456"
If you need 2 decimal places...
Code:
Dim number as decimal = 123456.789
MsgBox(number.ToString("n2")) ' = "123,456.79"
Last edited by .paul.; Feb 13th, 2025 at 07:30 AM.
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Feb 13th, 2025, 05:55 PM
#5
Thread Starter
Hyperactive Member
Re: [RESOLVED] Comma Formatting of number with leading Zeros removed
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|