1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| Function GetRound(ByVal Expression As String, Optional DecimalDigitsNumber As Byte = 2, Optional RoundToFive As Boolean = True) As Double
'Cette fonction sert à arrondir les valeurs comme la fonction ARRONDI de EXCEL
'Sur VB, la fonction intégrée Round ne correspond pas à celle d'Excel:
'Round(2.5,0)= 2 et ARRONDI(2.5,0)=3
Dim ApproximationValue As Single
If RoundToFive = True Then
ApproximationValue = 0.5
Else
ApproximationValue = 0.49
End If
GetRound = CDbl(Expression) * (10 ^ DecimalDigitsNumber)
GetRound = Int(GetRound + ApproximationValue) * (10 ^ -DecimalDigitsNumber)
End Function |