ciao bellissimo...
io ho trovato una funzione... vedi se può esserti utile...
codice:
Public Function Arrotonda (Importo As Double,Optional ArrDec As_
Double = 2,Optional ArrTipo As Double = 1,_
Optional Resto As Double = 0) As Double
'Funzione di arrotondamento
'Parametri di entrata:
'Importo = Importo da arrotondare
'ArrotDec = Numero decimali a cui arrotondare _
(Default=2)
'ArrotTipo = Tipo arrotondamento: _
(0=Nessuno/1=Matematico/2=Al decimale superiore/_
3=Al decimale inferiore)_
(Default=1)
'Parametri di uscita:
'Arrotonda = Importo arrotondato
'Resto = Differenza arrotondamento
Dim strImporto As String
Dim ImportoCom As Double
Dim strFormat As String
If ArrTipo = 1 Then
'Arrotondamento matematico.
'Viene eseguito automaticamente dalla Format$
strFormat$ = String$(24, "0")
If ArrDec > 0 Then
strFormat$ = strFormat$ & "." & String$(ArrDec, "0")
End If
strImporto$ = Format$(Importo, strFormat$)
ImportoCom = CDbl(strImporto$)
Else
'Altri tipi di arrotondamento
strImporto = Format$(Importo,_
"000000000000000000000000.000000000000000000")
If CDbl(Mid$(strImporto$, 26 + ArrDec, 43 - 25 - ArrDec))_
= 0 Then
'Nessun arrotondamento necessario
ImportoCom = Importo
Else
Select Case ArrTipo
Case 0
'Nessun arrotondamento
ImportoCom = CDbl(Mid$(strImporto$, 1, 25 + ArrDec))
Case 2
'Arrotondamento al decimale superiore
If CDbl(Mid$(strImporto$, 26 + ArrDec, _
43 - 25 - ArrDec)) > 0 Then
ImportoCom = CDbl(Mid$(strImporto$, 1, _
43 - 18 + ArrDec))
If ArrDec > 0 Then
ImportoCom = ImportoCom + CDbl("0," _
& String$(ArrDec - 1,"0") & "1")
Else
ImportoCom = ImportoCom + 1
End If
End If
Case 3
'Arrotondamento al decimale inferiore
ImportoCom = CDbl(Mid$(strImporto$, 1, 25 + ArrDec))
End Select
End If
End If
Arrotonda = ImportoCom
Resto = Importo - ImportoCom
End Function
ciao amichetto bello...