Rounding down to .00 .25 .50 .75

  • Thread starter Thread starter Guest
  • Start date Start date
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...
 
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 <--
 
Back
Top