Link to home
Start Free TrialLog in
Avatar of developingprogrammer
developingprogrammer

asked on

formatting number for thousands' comma #,###,###,###

hey guys!

i'm curious. if i have 2 numbers

9999
9999999999

and i want to insert commas in the thousands position to make it more readable so it'll look like this

9,999
9,999,999,999

i know i can do Format(strEndingBalance, "#,###,###,###.00")

and apply it to both numbers.

however what if i have another number

9999999999999999999999999999999999999999999999999999999999

(ok just ignore that no variable can store that hahaha - i think!! hrmm, can any variable store that number? i feel like Ali G asking the scientists about computers if they can multiply 999999999999991099910101010999 x 9999101099998910101010!! hahaha http://www.youtube.com/watch?v=eB5VXJXxnNU)

is there a format that i can use that will apply the comma at even interval recursively or must i type out a very very very long format string like the following?



Format(strEndingBalance, "#,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###,###.00")?

haha k that's REALLY LONG!!

is there anyway i can type out Format(strEndingBalance, "#,###") and make it recursive? thanks guys!! = ))
SOLUTION
Avatar of Bill Ross
Bill Ross
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of als315
als315
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of developingprogrammer
developingprogrammer

ASKER

whao guys, fantastic!! i didn't know about "Standard", i didn't know that #,### would repeat and definitely didn't know about the esoteric function FormatNumber!! haha great!! = )

in the end i decided to use

Format(CCur(varEndingBalance), """Credit:"" #,###.00;""Debit:"" #,###.00")

because that gave more control over the prefixes.

but thanks guys for all your help, appreciate it!! = ))