Round-functie [VBA]

De functie AFRONDEN geeft een afgerond getal terug met een bepaald aantal decimalen.

Waarschuwingspictogram

Deze functie of constante wordt ingeschakeld met de opdracht Option VBASupport 1 vóór de uitvoerbare programmacode in een module.


Syntaxis:

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

Geretourneerde waarde:

Double

Parameters:

Getal: Vereist. Het getal dat afgerond moet worden.

Aantal: Optioneel. Specificeert het aantal decimalen dat in de afronding wordt meegenomen. Standaard is dit 0.

Foutcodes:

5 Ongeldige aanroep van procedure

Voorbeeld:

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