Option Explicit
Public TimeOld As Variant
'---Funzione per calcolare il tempo del ciclo
Declare Function GetTickCount Lib "kernel32" () As Long
Public Declare Function SetTimer Lib "user32" ( _
ByVal HWnd As Long, _
ByVal nIDEvent As Long, _
ByVal uElapse As Long, _
ByVal lpTimerFunc As Long) As Long
Public Declare Function KillTimer Lib "user32" ( _
ByVal HWnd As Long, _
ByVal nIDEvent As Long) As Long
Public TimerID_1 As Long
Public TimerID_2 As Long
Public TimerSeconds As Single
Sub StartTimer_1()
Dim speed As Variant
speed = Foglio1.[A4] / 1000
Foglio1.[C4] = "Running."
If speed = 0 Then speed = 1
TimerSeconds = 0.1 ' how often to "pop" the timer.
TimerID_1 = SetTimer(0&, 0&, (TimerSeconds * 2500) + ((((TimerSeconds * 2500) / 10) * speed) / 10), AddressOf TimerProc_1) '0,5 secondi
End Sub
Sub EndTimer_1()
On Error Resume Next
KillTimer 0&, TimerID_1
Foglio1.[C4] = "Stopped."
End Sub
Sub TimerProc_1(ByVal HWnd As Long, ByVal uMsg As Long, _
ByVal nIDEvent As Long, ByVal dwTimer As Long)
On Error Resume Next
Foglio1.[C6] = Foglio1.[C6] + Foglio1.[A4] / 1000
DoEvents
End Sub
'------------------------------------------------------------
Sub StartTimer_2()
Dim speed As Variant
speed = Foglio1.[E4] / 1000
Foglio1.[G4] = "Running."
If speed = 0 Then speed = 1
TimerSeconds = 0.1 ' how often to "pop" the timer.
TimerID_2 = SetTimer(0&, 0&, (TimerSeconds * 2500) + ((((TimerSeconds * 2500) / 10) * speed) / 10), AddressOf TimerProc_2) '0,5 secondi
End Sub
Sub EndTimer_2()
On Error Resume Next
KillTimer 0&, TimerID_2
Foglio1.[G4] = "Stopped."
End Sub
Sub TimerProc_2(ByVal HWnd As Long, ByVal uMsg As Long, _
ByVal nIDEvent As Long, ByVal dwTimer As Long)
On Error Resume Next
Foglio1.[G6] = Foglio1.[G6] + Foglio1.[E4] / 1000
DoEvents
End Sub |