VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



The built in Round() function in VB does not round $$$ amounts correctly. The following Round Funct

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.

Rate The built in Round() function in VB does not round $$$ amounts correctly. The following Round Funct



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

Download this snippet    Add to My Saved Code

The built in Round() function in VB does not round $$$ amounts correctly. The following Round Funct Comments

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.

Post your comment

Subject:
Message:
0/1000 characters