UtterAccess HomeUtterAccess Wiki

Welcome Guest ( Log In | Register )

Custom Search
Edit Discussion
> RoundToNext    

This function was suggested by an UtterAccess discussion. The original poster needed to round values up to the next 5/100ths (.05). RoundToNext is a generic function that rounds the value argument to the next rounding factor level. So, a call to RoundToNext(105.241, .04) returns 105.28. The call roundtonext(105.241,.05) returns 105.25.

CODE
Public Function RoundToNext(ByVal rdblValue As Double, _
                           Optional rdblFactor As Double = 1)
' Procedure: RoundToNext
'
' Code courtesy of UtterAccess Wiki
' http://www.utteraccess.com/wiki/index.php/Category:FunctionLibrary
'
' You are free to use this code in any application,
' provided this notice is left unchanged.
'
' REV  DATE                          DESCRIPTION
' 1.0  2011-07-23             initial release
   
   Const cstrProcedure = "RoundToNext"
   
   RoundToNext = -Int(-rdblValue / rdblFactor) * rdblFactor

End Function

Creative Commons License
RoundToNext by UtterAccess Wiki is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Editing and revision of the content is freely encouraged; for details, see Expected Usage.

Edit Discussion
Custom Search
Thank you for your support!
This page has been accessed 2,214 times.  This page was last modified 07:27, 25 July 2011 by Glenn Lloyd.   Disclaimers