Solved

Round Function

Posted on 2003-11-06
2
2,253 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 44

Accepted Solution

by:
Arthur_Wood earned 30 total points
ID: 9697862
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
ID: 9698162
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

752 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