Round Function

Returns a value of the same type that is passed to it, rounded to a specified number of decimal places.

Syntax

Round([num,[NumAfterDecimal]])

The optional num argument is a Double or any valid numeric expression. If this argument is omitted, is a non-initialized variable, or Null, the function returns 0.

The optional NumAfterDecimal argument is an Int indicating how many places to the right of the decimal are included in the rounding. The default value is 0, that is integers are returned Round function (the decimal separator is not displayed then).

Remarks

Use this function to get numbers of needed accuracy. If the number of places to the right of the decimal is greater than NumAfterDecimal, the last non-zero digit is rounded by standard mathematical rules. If the number of places to the right of the decimal in num is less than NumAfterDecimal, extra zeros are not displayed.

Example

This example shows how Round is used in 3 cases: when the second argument is omitted, when the number of places to the right of the decimal is greater than the second argument, and vice versa.

Dim MyNumber
MyNumber = Round(99.8)   ' Returns 100
MyNumber = Round(25.125, 2)   ' Returns 25.13
MyNumber = Round(-45.753, 5)   ' Returns -45.753

 

See Also

Fix Function, Int Function , Type Conversion Functions