Solved

Rounding Decimals

Posted on 2000-03-03
4
491 Views
Last Modified: 2012-08-14
Fairly important to what I'm doing right now . . . .Is there a function that rounds decimals correctly, as Cint() rounds numbers x.5 to the nearest even number and Int() truncates them.

Thanks
0
Comment
Question by:G_Thompson
4 Comments
 
LVL 10

Accepted Solution

by:
paasky earned 50 total points
Comment Utility
Hello G_Thompson,

I think you can find the suitable function for you from this URL:

http://www.experts-exchange.com/jsp/qShow.jsp?ta=msaccess&qid=10300683

regards,
Paasky
0
 
LVL 7

Expert Comment

by:Dedushka
Comment Utility
In Acc2000 there is a new function Round(<number>,<precision>), but in online help it is not described. You can find it in object browser.
0
 
LVL 4

Expert Comment

by:wesleystewart
Comment Utility
This is a good rounding function:

http://www.mvps.org/access/modules/mdl0054.htm

Wes
0
 

Author Comment

by:G_Thompson
Comment Utility
Thank you all for your comments I'm not currently using Acces200 unfortunatly,

I altered one of the functions from a previous answer

Function Round(ToRound As Double) As Double
Dim Multiplier As Double
Dim DecimalP As Integer

DecimalP = 0
If (CInt(ToRound)) Mod 2 = 0 Then ToRound = ToRound + 0.1

Multiplier = 10 ^ DecimalP
Round = CLng(ToRound * Multiplier) / Multiplier
End Function

with out the 0.1 added to even numbers rounding 2.5 gave 2 with the addition of 0.1 it gives 3, correct

because the 0.1  is only added to even no's itdoes not affect other results .

I have just realised i could use

Function Round(value as double)

if cint(value)mod 2 <> 0 then
   round = cint(value+0.1)
Else
  round = cint(value)
endif

end function

For rounding to 0 dp

Thanks anyway

G Thompson
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…

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

14 Experts available now in Live!

Get 1:1 Help Now