Sub Calcul(JN$, test1 As Boolean, test2 As Boolean, horaire$, temp#)
If test1 + test2 = 0 Then Exit Sub
Dim deb#, fin1#, fin#, s, i%, s1, h1#, h2#
deb = [DN]: fin1 = [FN]: fin = fin1 + 1
horaire = Replace(Replace(horaire, "H", ":"), "24:", "0:")
s = Split(horaire)
For i = 0 To UBound(s)
s1 = Split(s(i), "-")
If UBound(s1) = 1 Then
h1 = CDate(s1(0))
If h1 < h2 Then h1 = h1 + 1
h2 = CDate(s1(1))
If h2 < h1 Then h2 = h2 + 1
If JN = "Jour" Then
If test1 Then
temp = temp - IIf(h2 > fin1, fin1, h2) + IIf(h1 > fin1, fin1, h1)
temp = temp + IIf(h2 > deb, deb, h2) - IIf(h1 > deb, deb, h1)
End If
If test2 Then temp = temp + IIf(h2 > fin, h2, fin) - IIf(h1 > fin, h1, fin)
Else 'Nuit
If test1 Then
temp = temp + IIf(h2 > fin1, fin1, h2) - IIf(h1 > fin1, fin1, h1)
If h1 < 1 And h2 > deb Then temp = temp + IIf(h2 > 1, 1, h2) - IIf(h1 > deb, h1, deb)
End If
If test2 And h1 < fin And h2 > 1 Then temp = temp + IIf(h2 > fin, fin, h2) - IIf(h1 > 1, h1, 1)
End If
End If
Next
End Sub