Trucs et astuces Express - L'aide informatique au bout des doigts!

Bienvenue invité ( Connexion | Inscription )

 
Reply to this topicStart new topic
> Arrondi De Calcul, Comment arrondir au nombre entier supérieur
Ivana
posté 17-10-2006 - 8:57
Message #1


Membre


Groupe : Membres
Messages : 30
Inscrit : 17-05-2006
Membre n° 9 727



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
Go to the top of the page
 
+Quote Post
Groumphy
posté 17-10-2006 - 14:14
Message #2


Modérateur loufoque et linuxien


Groupe : Modérateurs
Messages : 2 961
Inscrit : 26-11-2002
Lieu : Bruxelles
Membre n° 148



Src. Dev.com :

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


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


Basé sur :
principe Javascript


--------------------
----------------------------------
Blog (Archives)
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

 

RSS Version bas débit Nous sommes le : 22-11-2008 - 0:32
annuaire