Math.Round rounds a decimal to a specified number of fractional digits.
Imports System
Class Sample
Public Shared Sub Main()
Dim result As Decimal = 0D
Dim posValue As Decimal = 3.45D
Dim negValue As Decimal = -3.45D
result = Math.Round(posValue, 1)
Console.WriteLine(result)
result = Math.Round(negValue, 1)
Console.WriteLine(result)
result = Math.Round(posValue, 1, MidpointRounding.ToEven)
Console.WriteLine(result)
result = Math.Round(posValue, 1, MidpointRounding.AwayFromZero)
Console.WriteLine(result)
End Sub 'Main
End Class 'Sample
Related examples in the same category