Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
 
TitleRound a value to a specified number of digits in VB .NET
DescriptionThis example shows how to round a value to a specified number of digits in VB .NET by using the Math.Round method.
Keywordsround, round off, digits
CategoriesAlgorithms
 
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
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated