Round Function [VBA]

The Round function returns a number rounded to a specified number of digits.

警告图标

该功能或常量可通过以下语句启用:Option VBASupport 1,该语句需要放置在模块的每个可执行程序代码的前面。


语法:

Round( expression as Double [,numdecimalplaces as Integer] ) 

返回值:

Double

参数:

expression: Required. The numeric expression to be rounded.

numdecimalplaces: Optional. Specifies how many places to the right of the decimal are included in the rounding. Default is 0.

错误代码:

5 无效的过程调用

示例:

REM ***** BASIC *****

Option VBASupport 1

Sub Example_Round

 Dim r 

 r = Pi

 print r ' 3,14159265358979

 print Round(r, 5) ' 3,14159

 r = exp(1)

 print r ' 2,71828182845904

 print Round(r) ' 3

End Sub