Solved

Round Function

Posted on 2003-11-06
2
2,249 Views
Last Modified: 2010-05-18
I am trying to round some numbers..while 159.975 is rounding properly, 159.965 isnt.
Shouldn't VB always round up on the 5? It seems to only do it when the digit preceding
it is an odd number.

Round("159.965", 2)     ' RETURNS "159.96"  
Round("159.975", 2)     ' RETURNS "159.98"    

I tried the same thing with FormatCurrency and it works as I expect however I don't
want the dollar sign in front. It's a simple matter to strip the dollar sign with the Replace
function but would like an explanation about why the Round function behaves that way.
Is there a more elegant approach than stripping the '$' sign and using FormatCurrency?

Thanks
0
Comment
Question by:const71
2 Comments
 
LVL 44

Accepted Solution

by:
Arthur_Wood earned 30 total points
Comment Utility
this is a STANDARD rounding procedure for VB.  It is known as "Banker's Rounding", and is discussed at length at

http://support.microsoft.com/default.aspx?scid=kb;EN-US;196652

AW


0
 

Author Comment

by:const71
Comment Utility
yes but the two methods i showed you provide 2 different ways of rounding. I'll read the article and see what it says...


thanks

0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now