string.Format newb

  • Thread starter Thread starter mp
  • Start date Start date
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
 
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!
 
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
 
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....
 
Back
Top