Math.Round Function in VB.NET

Topic

What is Math.Round function in VB.NET?

Explanation

Math.Round Function

Math.Round in VB.NET is a mathematical function that is used to return whole number nearest to value for the specified number of decimal places.
Syntax:

Math.Round(Number,Decimal Places)

In the above syntax Number is the number to be rounded to the number of Decimal Places.
Example:

Module Module1
Sub Main()
Console.WriteLine("Rounded value of 6.42::"
& Math.Round(6.42, 1))
Console.WriteLine("Rounded value of 6.56::"
& Math.Round(6.56, 1))
Console.WriteLine("Rounded value of 6.49::"
& Math.Round(6.49, 1))
Console.ReadLine()
End Sub
End Module
Result:

Rounded value of 6.42:: 6.4
Rounded value of 6.56:: 6.6
Rounded value of 6.49:: 6.5

In the above example, the Math.Round mathematical function is used to round the decimal number for a single decimal place.

Visual Basic Tutorial