Public Shared Function RoundUp(ByVal value As Decimal, ByVal decimalPlaces As UInt32) As Decimal
Dim rate As Decimal = CDec(Math.Pow(10.0R, decimalPlaces))
If value < 0 Then
Return (Math.Ceiling(value * -1D * rate) / rate) * -1D
Else
Return Math.Ceiling(value * rate) / rate
End If
End Function
Public Shared Function RoundDown(ByVal value As Decimal, ByVal decimalPlaces As UInt32) As Decimal
Dim rate As Decimal = CDec(Math.Pow(10.0R, decimalPlaces))
If value < 0 Then
Return (Math.Floor(value * -1D * rate) / rate) * -1D
Else
Return Math.Floor(value * rate) / rate
End If
End Function
Public Shared Function Round(ByVal value As Decimal, ByVal decimalPlaces As UInt32) As Decimal
Return Math.Round(value, CInt(decimalPlaces), MidpointRounding.AwayFromZero)
End Function