by Ertan Zanagar (2 Submissions)
Category: Math/Dates
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Mon 8th July 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)
The built in Round() function in VB does not round $$$ amounts correctly. The following Round Function will do it correctly.
Function RoundPennies(piNum)
Dim newNum
newNum = CDbl(Round(piNum, 2))
If (CDbl(newNum) < CDbl(piNum) And CDbl(piNum - newNum) >= CDbl(0.005)) Then
newNum = newNum + CDbl(0.01)
End If
RoundPennies = newNum
End Function
No comments have been posted about The built in Round() function in VB does not round $$$ amounts correctly. The following Round Funct. Why not be the first to post a comment about The built in Round() function in VB does not round $$$ amounts correctly. The following Round Funct.