formatcurrency not showing zero at end
I have the following:
VB Code:
dim curWeeklyEarning as currency
curWeeklyEarning = CCur((colHours.getTotalMinutesOfSupport / 60) * curHourlyRate)
curWeeklyEarning = FormatCurrency(curWeeklyEarning, 2)
colHours returns a long which i multiply by an hourly rate. My problem is in the format currency, where it won't display the trailing zero. For example, if a user works 3 hours, and gets paid £6.50 per hour, the following code will return the currency of 19.5 instead of 19.50.
How can i enforce the zero on the end?
Re: formatcurrency not showing zero at end
FormatCurrency outputs a string - which you are coercing into a number - so you're bound to loose all the formatting:
VB Code:
Dim curWeeklyEarning As Currency
curWeeklyEarning = CCur((colHours.getTotalMinutesOfSupport / 60) * curHourlyRate)
MsgBox FormatCurrency(curWeeklyEarning, 2)
Re: formatcurrency not showing zero at end
I see. Is there any other function that can be used? What would be the best way of achieving the above then?
Thanks for your quick reply :)
Re: formatcurrency not showing zero at end
Quote:
Originally Posted by skinny monkey
I see. Is there any other function that can be used? What would be the best way of achieving the above then?
Thanks for your quick reply :)
I don't see what you mean? The best way of achieving what?
A number is a number - they don't have any leading or trailing zeros (otherwise they'd be infinitely long). When you come to display the number to your user you format it into a string which will allow you to add leading and trailing zeros.
Re: formatcurrency not showing zero at end
You can use formatnumber() to format a number but the result wil be a string of course just like formatcurrency() does.
Ypur problem is probably cause by doing some math before you display the variable or assigning it to the value property instead of the text propperty
Re: formatcurrency not showing zero at end
Adding to above, either you can define curWeeklyEarning as string or you can use format functions.
VB Code:
Dim curWeeklyEarning As [B]String[/B]
'or
Debug.Print Format(curWeeklyEarning, "0.00")