Round Function


Round Function

Class

System.Math

Syntax

     Dim result As type = Math.Round(value[, mode]) 

or

     Dim result As type = Math.Round(value, digits[, mode]) 


type (required)

One of the following data types: Decimal or Double.


value (required; any expression of type type)

A number to be rounded.


mode (optional; MidpointRounding enumeration)

New in 2005. Indicates how to round numbers found at the halfway point between two rounding options, from the System.MidpointRounding enumeration. The AwayFromZero value rounds in the opposite direction of zero, while ToEven rounds toward the nearest even number (in the least significant decimal place). If not supplied, ToEven is used by default.


digits (optional; Integer)

The number of places to include after the decimal point and at which to perform the rounding.

Description

The Round function rounds a given number to a specified number of decimal places.

Usage at a Glance

  • digits can be any whole number between 0 and 28.

  • This is a shared member of the System.Math class, so it can be used without an instance.

  • If value contains fewer decimal places than digits, Round does not pad the return value with trailing zeros.

Version Differences

  • The named parameters of the Round function differ in VB 6 and in the .NET Framework. In VB 6, the named arguments are number and numDigitsAfterDecimal. In .NET, they are value and digits.

  • The mode parameter was added in the 2005 release of the .NET Framework.

See Also

Fix Function, Int Function




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net