468,774 Members | 2,629 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,774 developers. It's quick & easy.

Format Function Not Working with Currency

Hello all! I'm having the oddest issue trying to format a numeric
string as currency without decimals. For instance...

strSalary = "120000.56"

strSalary = Format(strSalary, "$#,##0")
'this one returns "$#,##0" literally, no number

strSalary = Format(strSalary, "C0")
'this one returns "C0" literally, no number

strSalary = Format(strSalary, "currency")
'this one actually formats the number as currency, but is has decimal
places! So close, yet so far...

Am I missing something????

Thanks you,
Cory

Jun 7 '06 #1
2 1395
In order for Format to work the way you want, you must pass in a
numeric type not a string.
strSalary = Format(strSalary, "$#,##0")
'this one returns "$#,##0" literally, no number
Dim dSalary as Decimal = 120000.56
strSalary = Format(strSalary, "$#,##0")

cr********@gmail.com wrote: Hello all! I'm having the oddest issue trying to format a numeric
string as currency without decimals. For instance...

strSalary = "120000.56"

strSalary = Format(strSalary, "$#,##0")
'this one returns "$#,##0" literally, no number

strSalary = Format(strSalary, "C0")
'this one returns "C0" literally, no number

strSalary = Format(strSalary, "currency")
'this one actually formats the number as currency, but is has decimal
places! So close, yet so far...

Am I missing something????

Thanks you,
Cory


Jun 7 '06 #2
Thank you! That's exactly what I needed to know. I simply wrapped the
string variable in the CDbl function and it worked perfectly. I'd
thought you could format strings as numbers so long as the characters
were all numeric such as with the "currency" type.

strSalary = Format(CDbl(strSalary), "C0")

Thanks again!

Jun 7 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Bill Stanard | last post: by
4 posts views Thread by Patrick J. Schouten | last post: by
2 posts views Thread by Dalan | last post: by
2 posts views Thread by DD | last post: by
1 post views Thread by J.B | last post: by
1 post views Thread by D. Shane Fowlkes | last post: by
1 post views Thread by Parveen | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
2 posts views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.