Bonjour à tous,
Dans un formulaire Access, je calcule une durée en jours en soustrayant la date de début de la date de fin, durée que je ramène en semaines par une division. Le problème se pose quand la durée ne fait pas un nombre exact de semaines s'il y a un jour férié. Est-il possible de demander un arrondi supérieur dans mon expresion ?
Merci d'avance
Ivana
Page 1 sur 1
Arrondi De Calcul Comment arrondir au nombre entier supérieur
#2
Posté 17 octobre 2006 - 02:14
Src. Dev.com :
Basé sur :
principe Javascript
CODE
Function RoundCost(ByVal Nbr As Double, _
Optional ByVal Expo As Long = 2, Optional ByVal NextNumSup = 5) As Double
'Expo is the number of desired decimals
'NextNumSup is the min number after the Expo decimal which result in a Roundsup for Nbr
'Exemple : Roundcost(0.44X) = 0.45 if X >= NextNumSUp (5 by default)
'Correct bug for RoundSup(0.445) = 0.44
If Expo < 0 Then RoundCost = RoundCost(Nbr * 10 ^ Expo, Abs(Expo))
RoundCost = CLng(Nbr * 10 ^ Expo + (0.01 * (10 - NextNumSup))) / 10 ^ Expo
End Function
Optional ByVal Expo As Long = 2, Optional ByVal NextNumSup = 5) As Double
'Expo is the number of desired decimals
'NextNumSup is the min number after the Expo decimal which result in a Roundsup for Nbr
'Exemple : Roundcost(0.44X) = 0.45 if X >= NextNumSUp (5 by default)
'Correct bug for RoundSup(0.445) = 0.44
If Expo < 0 Then RoundCost = RoundCost(Nbr * 10 ^ Expo, Abs(Expo))
RoundCost = CLng(Nbr * 10 ^ Expo + (0.01 * (10 - NextNumSup))) / 10 ^ Expo
End Function
CODE
Function Arrondi(ByVal Nbre As Double, ByVal Expo As Long) As Double
If Expo < 0 Then Arrondi = Arrondi(Nbre * 10 ^ Expo, Abs(Expo))
Arrondi = CLng(Nbre * 10 ^ Expo) / 10 ^ Expo
End Function
If Expo < 0 Then Arrondi = Arrondi(Nbre * 10 ^ Expo, Abs(Expo))
Arrondi = CLng(Nbre * 10 ^ Expo) / 10 ^ Expo
End Function
Basé sur :
principe Javascript
Page 1 sur 1


Connexion
Inscription
Aide
Retour en haut
Multi-citation