Returns a number rounded to a specified number of decimal places.
|
---|
Round(expression[, numdecimalplaces]) |
Arguments
- expression
Required. Numeric expression being rounded.
- numdecimalplaces
Optional. Number indicating how many places to the right of the decimal are included in the rounding. If omitted, integers are returned by the Round function.
Remarks
Example
The following example uses the Round function to round a number to two decimal places:
| Copy Code |
---|
Dim MyVar, pi
pi = 3.14159
MyVar = Round(pi, 2) ' MyVar contains 3.14. |
This example demonstrates how rounding to even works:
| Copy Code |
---|
Dim var1, var2, var3, var4, var5
var1 = Round(1.5) ' var1 contains 2
var2 = Round(2.5) ' var2 contains 2
var3 = Round(3.5) ' var3 contains 4
var4 = Round(0.985, 2) ' var4 contains 0.98
var5 = Round(0.995, 2) ' var5 contains 1.00 |
Requirements
See Also