Re: Cannot get format to work
- From: "MikeD" <nobody@xxxxxxxxxxx>
- Date: Sun, 28 Oct 2007 18:42:43 -0400
"nod" <nod@xxxxxxxxxx> wrote in message
news:nsr9i3p6jboaeot792vuflf3nk302i6tgg@xxxxxxxxxx
I have a variable called 'cost'
It is a number rounded up to 2 decimal places.
I need to display it in a Rich Text box using a comma separator for
thousands and always displaying two digits to the right of the decimal
point.
To do so I have tried numerous permutations declaring cost both as
Currency and Double along with:
FormatCurrency( cost,2)
Format( cost,"#,##0.00")
Format|(cost,"Fixed")
Format|(cost,"Standard")
Nothing works for me.
I would be grateful ifsomeone could tell me what I am doing wrong.
You should really explain "Nothing works". What result(s) ARE you getting?
Is it just the format that's not right or is the value off by a small amount
(probably only by .01)?
FormatCurrency is locale-aware. So, if your regional settings are set to
use something other than a comma for the thousands separator, that's what
you'll get. The same goes for the currency symbol and the decimal symbol.
But, using Format and a user-defined format string (your second example)
should be using a comma for the thousands separator regardless of regional
settings. Perhaps that will shed some light if the problem is just the
formatting.
If the value itself is off, then it might be due to Format (or
FormatCurrency) itself doing some rounding. Pay close attention to the
ACTUAL value that you're formatting because it might have 3 or more decimal
places (and since you're formatting for 2 decimal places, it could be
getting rounded again).
If you still can't get this sorted out, post back but include the ACTUAL AND
COMPLETE value you're attempting to format.
--
Mike
Microsoft MVP Visual Basic
.
- Follow-Ups:
- Re: Cannot get format to work
- From: nod
- Re: Cannot get format to work
- References:
- Cannot get format to work
- From: nod
- Cannot get format to work
- Prev by Date: Re: Cannot get format to work
- Next by Date: Re: Cannot get format to work
- Previous by thread: Re: Cannot get format to work
- Next by thread: Re: Cannot get format to work
- Index(es):
Relevant Pages
|