Dim Phour As strig '你要定时的小时 Dim Ptime As String '你要定时的分钟'将timer控件的Interval设为60000(一分钟) Private Sub Timer1_Timer() Dim THour As Integer '用于赋值的中间变量 Dim TMinute As Integer '用于赋值的中间变量
If Phour <> "" And PMinute <> "" Then If Len(Hour(Time)) = 1 Then THour = "0" & Hour(Time) Else THour = Hour(Time) End If
If Len(Minute(Time)) = 1 Then TMinute = "0" & Minute(Time) Else TMinute = Minute(Time) End If
If THour = Phour And (TMinute >= Val(PMinute) _ And TMinute < Val(PMinute + 1)) Then Command1_Click '你要触发的时间代码 End If End If End Sub'这种方法可以保证在你设定的那一分钟内发生你要的代码, '但是不保证一到这一分钟就立刻发生? '好处是Timer控件一分钟才触发一次,足够省资源了
加个Timer Private Sub Timer1_Timer() Dim strCurTime As String strCurTime = Format(CStr(Time), "hh:mm:ss") Label1.Caption = Now k = k + 1 If k = 10 Then btnUpdate.Enabled = True k = 0 End If If strCurTime = "08:00:00" Or strCurTime = "12:30:00" Or strCurTime = "18:30:00" Then 'Joy YourSelf! End If End Sub
简化一下,上面粘贴一些多余的 Private Sub Timer1_Timer() Dim strCurTime As String strCurTime = Format(CStr(Time), "hh:mm:ss") If strCurTime = "08:00:00" Or strCurTime = "12:30:00" Or strCurTime = "18:30:00" Then 'Joy YourSelf! End If End Sub
执行了我的程序,让程序自动判断时间,当到达某个时间,就执行几个语句这样啊??
至于你的自动判断时间,执行目的语句的功能,就需要在你的程序里编程来
处理,这是完全可行的
比如我做过一个复制Oracle日志文件的程序,实际上就是每周计划任务中执行这
个程序,但是程序中来判断Oracle日志文件的文件名变化及容量总和大小的变化
,满足一定条件之后就把现在的日志复制到磁带机,然后删除,继续等待检查和你的要求差不多
Dim Phour As strig '你要定时的小时
Dim Ptime As String '你要定时的分钟'将timer控件的Interval设为60000(一分钟)
Private Sub Timer1_Timer()
Dim THour As Integer '用于赋值的中间变量
Dim TMinute As Integer '用于赋值的中间变量
If Phour <> "" And PMinute <> "" Then
If Len(Hour(Time)) = 1 Then
THour = "0" & Hour(Time)
Else
THour = Hour(Time)
End If
If Len(Minute(Time)) = 1 Then
TMinute = "0" & Minute(Time)
Else
TMinute = Minute(Time)
End If
If THour = Phour And (TMinute >= Val(PMinute) _
And TMinute < Val(PMinute + 1)) Then
Command1_Click '你要触发的时间代码
End If
End If
End Sub'这种方法可以保证在你设定的那一分钟内发生你要的代码,
'但是不保证一到这一分钟就立刻发生?
'好处是Timer控件一分钟才触发一次,足够省资源了
Private Sub Timer1_Timer()
Dim strCurTime As String
strCurTime = Format(CStr(Time), "hh:mm:ss")
Label1.Caption = Now
k = k + 1
If k = 10 Then
btnUpdate.Enabled = True
k = 0
End If
If strCurTime = "08:00:00" Or strCurTime = "12:30:00" Or strCurTime = "18:30:00" Then
'Joy YourSelf!
End If
End Sub
Private Sub Timer1_Timer()
Dim strCurTime As String
strCurTime = Format(CStr(Time), "hh:mm:ss")
If strCurTime = "08:00:00" Or strCurTime = "12:30:00" Or strCurTime = "18:30:00" Then
'Joy YourSelf!
End If
End Sub
命令格式为:at \\IP地址 [时间] [文件名]
可以在計劃任務內添加你的任務