Round Up or Down to the Nearest Specified Value

Category:
Dates and Math
Type:
Snippets
Difficulty:
Intermediate
Author:
Chris Hanscom

Version Compatibility: Visual Basic 5

More information:
Used to round values to the nearest value; i.e. round 4.2 to the nearest .25 would be 4.25 (can set whether it rounds up or down). Cut and Paste into a standard module to use:

  • nValue = Original value
  • nCeiling = Value to round to (i.e. .125 / .25)

Instructions: Copy the declarations and code below and paste directly into your VB project.

Declarations:

Code: