by Jacky Wong (2 Submissions)
Category: Math/Dates
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (3 Votes)
I found the round function from the vbcoders.com 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.
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