Content
Resources
To Do
Toolbox

 RoundToNext
(Difference between revisions)
 Revision as of 13:39, 23 July 2011Argeedblu (Talk | contribs)← Previous diff Current revisionArgeedblu (Talk | contribs) (add function declaration to code) Line 1: Line 1: This function was suggested by an UtterAccess [http://www.utteraccess.com/forum/index.php?s=&showtopic=1970622&view=findpost&p=2137530 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. This function was suggested by an UtterAccess [http://www.utteraccess.com/forum/index.php?s=&showtopic=1970622&view=findpost&p=2137530 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]' Procedure: RoundToNext + [code]Public Function RoundToNext(ByVal rdblValue As Double, _ + Optional rdblFactor As Double = 1) + ' Procedure: RoundToNext ' ' ' Code courtesy of UtterAccess Wiki ' Code courtesy of UtterAccess Wiki

## Current revision

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