如何用VB编写,在系统时间为8秒(18秒,28秒,38,48秒,58秒)的时候执行某个动作?

来源:百度知道 编辑:UC知道 时间:2024/07/05 05:28:03
如何用VB编写,在系统时间为8秒(18秒,28秒,38,48秒,58秒)的时候执行某个动作?
当时间不是8秒尾数的时候跳过,过0.3秒重新检测,一旦系统时间(秒数)符合要求的时候,进行执行主程序。

添加Timer控件,设置Interval属性为300
Private Sub Timer1_Timer()
a=Second(Time)
If (Val(a)-8) Mod 10 = 0 Then
'你的代码
End If
End Sub

加一个Timer控件,interval=300
Timer事件:
if Second (now) mod 10=8 then
'执行某个动作
end if

timer的Interval设为300
Private Sub Timer1_Timer()
Dim nt As Integer
nt = Format(Time, "ss")
If nt Mod 10 = 8 Then
shell "calc.exe" '打开windows本身的计算器
end if
End Sub

timer的Interval设为300
Private Sub Timer1_Timer()
Dim nt As Integer
nt = Format(Time, "ss")
If nt Mod 10 = 8 Then
执行主程序
end if
End Sub

Private Sub Timer1_Timer()
If Second(Now) = 18 Or Second(Now) = 28 Or Second(Now) = 38 Or Second(Now) = 48 Or Second(Now) = 58 Then
MsgBox ""
End If
End Sub

把Interval设置小一点,加一个逻辑值判断一下是否已经执行过过程