用 Timer 控件.如: Option ExplicitPrivate Sub Form_Load() Timer1.Enabled = True Timer1.Interval = 100 End Sub Private Function def_Function() MsgBox "时间到了" End FunctionPrivate Sub Timer1_Timer() If Time > CDate("20:00:00") And Time < CDate("20:01:00") Then '设置如果是20:00:00-20:01:00之间就运行, Call def_Function Timer1.Enabled = False '设置只运行一次 End If End Sub
Option ExplicitPrivate Sub Form_Load()
Timer1.Enabled = True
Timer1.Interval = 100
End Sub
Private Function def_Function()
MsgBox "时间到了"
End FunctionPrivate Sub Timer1_Timer()
If Time > CDate("20:00:00") And Time < CDate("20:01:00") Then '设置如果是20:00:00-20:01:00之间就运行,
Call def_Function
Timer1.Enabled = False '设置只运行一次
End If
End Sub