|
|
|
| Title | Round a value to a specified number of digits in VB .NET |
| Description | This example shows how to round a value to a specified number of digits in VB .NET by using the Math.Round method. |
| Keywords | round, round off, digits |
| Categories | Algorithms |
|
|
|
The Math.Round method takes two parameters giving the number to round and the number of digits you want to round at.
|
|
Imports System.Math
Private Sub btnGo_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnGo.Click
Dim value As Double = Double.Parse(txtValue.Text)
Dim digits As Integer = Integer.Parse(txtDigits.Text)
Dim result As Double = Round(value, digits)
txtResults.Text = result.ToString()
End Sub
|
| |
|
| |
|
|