7,763
社区成员
发帖
与我相关
我的任务
分享
Option Explicit
Dim sum As Integer
Dim sum1 As Integer
Private Sub Form_Load()
Timer1.Interval = 500
End Sub
Private Sub Timer1_Timer()
If Label1.Caption <> CStr(Time) Then
Label1.Caption = Time$
sum = sum + 1
Label2 = sum
If sum >= 5 Then 'sum >= 5及以下sum1 >= 12的写法可确保按间隔需执行的代码不会遗漏,仅时间可能有偏差
'处理每5秒需执行的事的代码
sum = sum - 5
sum1 = sum1 + 1
Label3 = sum1 * 5
If sum1 >= 12 Then
sum1 = sum1 - 12
'处理每60秒需执行的事的代码
End If
End If
End If
End Sub