Private Sub CommandButton1_Click() 'bouton lancer la simulation Range("A1") = 0 Do While Range("A1") <> 1 Call boucle Range("C5").Value = Range("C5").Value + 0.05 Range("A2") = Range("A2") + 1 Loop End Sub Private Sub CommandButton2_Click() 'bouton arreter la simulation Range("A1") = 1 End Sub Sub boucle() 'corps de la simulation Dim pausetime, start intervalle = 0.02 'intervalle de l'horloge 'boucle de tempo start = Timer Do While Timer < start + intervalle DoEvents Loop End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionet ça ne plante plus, et le ventilateur de l'ordi ne s'emballe plus.
Private Declare Function GetInputState Lib "user32" () As Long Private Sub CommandButton1_Click() 'bouton lancer la simulation Range("A1") = 0 Do While Range("A1") <> 1 Call boucle Range("C5").Value = Range("C5").Value + 0.05 Range("A2") = Range("A2") + 1 Loop End Sub Private Sub CommandButton2_Click() 'bouton arreter la simulation Range("A1") = 1 End Sub Sub boucle() 'corps de la simulation Dim pausetime, start intervalle = 0.02 'intervalle de l'horloge 'boucle de tempo start = Timer Do While Timer < start + intervalle If GetInputState <> 0 Then DoEvents Loop End Sub