Decimal Rounding Function

Category:
Dates and Math
Type:
Snippets
Difficulty:
Intermediate
Author:
Ethan

Version Compatibility: Visual Basic 6, Visual Basic 5

More information:
This code will round a any number to the designated decimal place The Decimal portion is optional. Leaving it out or as a zero will round to the nearest whole number.

Sample:

Dim Number Number = 23456.12456 roundNumber Number,4

The resulting number will equal 23456.1246 Number = roundNumber(23456.52456) Resulting Number = 23457

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

Declarations:

Code: