Rounding down to .00 .25 .50 .75

G

Guest

I've searched all the various rounding posts and can't find my solution. I
need to round a number that I calculate in vb down to the nearest .25. For
example 27.49 needs to be changed to 27.25 etc. Following is the required
logic:

If less than .24 round down to .00
If value is .49 or less round down to .25
If less than .75 round down to .50
If .99 or less round down to .75

My Access and vb are self taught and I really appreciate all your posts!

Thanks in advance...
 
S

Stefan Hoffmann

hi Patty,
I've searched all the various rounding posts and can't find my solution.
There was one, but I can't rember...
need to round a number that I calculate in vb down to the nearest .25. For
example 27.49 needs to be changed to 27.25 etc. Following is the required
logic:
It is done like that:

http://www.exceltip.com/st/Rounding_Prices_to_the_Nearest_Nickel,_Dime,_Quarter_and_Dollar/1105.html

Try this one:

Public Function RoundTo(AValue As Double, ADivisor As Long) As Double

RoundTo = Round(AValue * ADivisor) / ADivisor

End Function

I'm not sure whether this must be Round() or Int() in the function.


mfG
--> stefan <--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top