Option Explicit
Private TPlanifications() As Planification, Idt As Long
Rem. En principe vous ne devriez pas avoir besoin de cette procédure, qui désactive tous les objets Planification.
Public Sub DéplanifierTout()
Dim P As Long, M As Long
On Error Resume Next: M = UBound(TPlanifications): If Err Then Exit Sub
On Error GoTo 0
For P = 1 To M: Idt = Idt Mod M + 1
If Not TPlanifications(Idt) Is Nothing Then TPlanifications(Idt).Annuler
Set TPlanifications(Idt) = Nothing: Next P
End Sub
Rem. Ne pas utiliser ces autres procédures: elles sont à l'usage exclusif des objets Planification.
Public Function IdtPlanificationLancée(ByVal Source As Planification) As Long
Dim P As Long, M As Long
On Error Resume Next: M = UBound(TPlanifications): If Err Then ReDim TPlanifications(1 To 1): M = 1
On Error GoTo 0
For P = 1 To M: Idt = Idt Mod M + 1: If TPlanifications(Idt) Is Nothing Then Exit For
Next P: If P > M Then ReDim Preserve TPlanifications(1 To P): Idt = P
Set TPlanifications(Idt) = Source
Application.OnTime Source.HeureOT, "'MPlanificateur.OnTimeJoue " & Idt & "'"
IdtPlanificationLancée = Idt
End Function
Public Sub AnnulerPlanification(ByVal Idt As Long)
On Error Resume Next
Application.OnTime TPlanifications(Idt).HeureOT, "'MPlanificateur.OnTimeJoue " & Idt & "'", Schedule:=False
Set TPlanifications(Idt) = Nothing
End Sub
Private Sub OnTimeJoue(ByVal Idt As Long)
On Error Resume Next
TPlanifications(Idt).MéthodeRéservéeÀOnTimeJoue
Set TPlanifications(Idt) = Nothing
End Sub