README.md

December 5, 2022 ยท View on GitHub

Round, Ceiling, Floor Function

Description

I found the round function from the planet source code before and I grouped it with my own ceil and floor function together. I hope these could help someone who don't want to use the round and format function to handle the numeric information.

More Info

Submitted On
ByJacky Wong
LevelBeginner
User Rating4.3 (13 globes from 3 users)
CompatibilityVB 6.0
CategoryMath/ Dates
WorldVisual Basic
Archive File

Source Code

Public Function AdvRound(InValue As Double, InDecimal As Integer) As Double
Dim lDblProcess As Double

lDblProcess = InValue * (10 ^ InDecimal)
AdvRound = Int(lDblProcess + 0.5) / (10 ^ InDecimal)
End Function

Public Function AdvCeil(InValue As Double, InDecimal As Integer) As Double
Dim lDblProcess As Double
lDblProcess = InValue * (10 ^ InDecimal)
If Int(lDblProcess) < lDblProcess Then
lDblProcess = Int(lDblProcess) + 1
Else
lDblProcess = Int(lDblProcess)
End If
AdvCeil = lDblProcess / (10 ^ InDecimal)
End Function

Public Function AdvFloor(InValue As Double, InDecimal As Integer) As Double
Dim lDblProcess As Double
lDblProcess = InValue * (10 ^ InDecimal)
AdvFloor = Int(lDblProcess) / (10 ^ InDecimal)
End Function