Option Explicit
Const Bon As Double = 4
Function Phien(Dat1 As Date, Dat2 As Date)
Dim jJ As Byte: ReDim MDL(1 To 6, 1 To 2)
For jJ = 2 To 6
MDL(jJ, 1) = "": MDL(jJ, 2) = ""
Next jJ
Phien = Hour(Dat2 - Dat1)
MDL(1, 1) = TimeSerial(Hour(Dat1), Minute(Dat1), Second(Dat1))
If Phien < 4 Then
MDL(1, 2) = TimeSerial(Hour(Dat2), Minute(Dat2), Second(Dat2))
Else
MDL(1, 2) = TimeSerial(Hour(Dat1) + Bon, Minute(Dat1), Second(Dat1))
For jJ = 2 To 2 + Phien \ 4 + 1
MDL(jJ, 1) = _
TimeSerial(Hour(Dat1) + (jJ - 1) * Bon, Minute(Dat1) + (jJ - 1) * 10, Second(Dat1))
MDL(jJ, 2) = TimeSerial(Hour(Dat1) + jJ * Bon, Minute(Dat1) + (jJ - 1) * 10, Second(Dat1))
If MDL(jJ, 2) > TimeSerial(Hour(Dat2), Minute(Dat2), Second(Dat2)) Then
MDL(jJ, 2) = TimeSerial(Hour(Dat2), Minute(Dat2), Second(Dat2))
Exit For
End If
Next jJ
End If
Phien = MDL
End Function