Any of the Words
Link to us
One Line RoundUp / One Line RoundDown
Replaces http://www.a1vbcode.com/snippet-2916.asp -=Description from 2916 follows=- Two simple functions that are not found in VB. Suppose you have a number '3.376'. Now when you will use the RoundUp function you will get the result as '4.0'. By using RoundDown function the result would be '3.0'. However, for .NET you could use the Math.Floor and Math.Ceiling methods.
Public Function RoundUp(Number As Double, Optional Places As Long = 0) As Double RoundUp = Round(Number + (5 / (10 ^ (Abs(Places) + 1))), Abs(Places)) End Function Public Function RoundDown(Number As Double, Optional Places As Long = 0) As Double RoundDown = Round(Number - (5 / (10 ^ (Abs(Places) + 1))), Abs(Places)) End Function
© 2018 A1VBCode. All rights reserved.