Round 函数 [VBA]

Round 函数返回取整到指定位数的数字。

warning

将语句 Option VBASupport 1 放在模块中的可执行程序代码之前, 启用此函数或常量。


语法:


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

返回值:

Double

参数:

expression」: 必填。要取整的数字表达式。

numdecimalplaces」: 可选。指定取整过程中小数点后应保留多少位。默认为 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