README.md

December 3, 2022 ยท View on GitHub

Another (very easy) Rounding Function

Description

This code makes easy work of doing simple rounding on decimal number...something that VB currently lacks. Why didn't they think of this?

More Info

Number (double data type)

RoundNum (Integer)

Rounding financial stuff is not cool :)

Submitted On
ByMatt Roberts
LevelIntermediate
User Rating4.6 (23 globes from 5 users)
CompatibilityVB 4.0 (16-bit), VB 4.0 (32-bit), VB 5.0, VB 6.0, VB Script
CategoryVB function enhancement
WorldVisual Basic
Archive File

Source Code

' Paste this code directly into your IDE. This has not yet been tested on VBScript, but should work if you drop the type declarations.
Function RoundNum(Number As Double) As Integer
If Int(Number + 0.5) > Int(Number) Then
  RoundNum = Int(Number) + 1
Else
  RoundNum = Int(Number)
End If
End Function