Funció Round [VBA]

La funció Round retorna un nombre arrodonit a una quantitat de dígits especificada.

warning

Aquesta funció o constant s'activa amb l'expressió Option VBASupport 1 plaçada en un mòdul abans del codi executable.


Sintaxi:


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

Valor de retorn:

Double

Paràmetres:

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.

Codis d'error

5 La crida al procediment no és vàlida

Exemple:


        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
    

Ens cal la vostra ajuda!