string.Format newb

M

mp

given
Excel.Range rng1 = _xlWorkSheet.get_Range(rangeName, Type.Missing);
string cash = String.Format("{0: ###,###.##}",
rng1.Value2);

I get the string "123,546"
but it should be "123,546.00"

what am i doing wrong?
thanks
mark
 
J

Jeff Johnson

given
Excel.Range rng1 = _xlWorkSheet.get_Range(rangeName, Type.Missing);
string cash = String.Format("{0: ###,###.##}",
rng1.Value2);

I get the string "123,546"
but it should be "123,546.00"

what am i doing wrong?

Forgetting even your basic VB training, that's what. Using 0 as a
placeholder instead of # FORCES a digit there, even if it's 0. Format$()
uses the same rules; I'm surprised you've never run across it before. Tsk
tsk, Mark!
 
M

mp

Jeff Johnson said:
Forgetting even your basic VB training, that's what. Using 0 as a
placeholder instead of # FORCES a digit there, even if it's 0. Format$()
uses the same rules; I'm surprised you've never run across it before. Tsk
tsk, Mark!

yeah i'm even more ashamed of me than you are
:)
i've probably seen it in the dim past but dont' recall ever having to use
it.
it did eventually surface in my brain but took a while
:)
you're awfully gentle in your upbrading(compared to what i deserve)...must
be in the christmas spirit
 
J

Jeff Johnson

you're awfully gentle in your upbrading(compared to what i deserve)...must
be in the christmas spirit

I'll consider that a challenge for your next post....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top