想从某个时间点开始,每间隔2分钟,执行一次命令,写了代码不知为何到点不执行,请大家帮忙分析原因!谢谢!!!
我的代码:从8:00:00开始每隔2分钟Text1.Text显示OK
Dim ks As Date, XZ As Date
Private Sub Timer1_Timer()
Dim k
ks = "8:00:00"
XZ = Time
k = 2 * (Fix((60 * (Format(CDate(XZ - ks), "h")) + Format(CDate(XZ - ks), "n")) / 2) + 1)
If Time = DateAdd("N", k, ks) Then
Text1.Text = "OK"
End If
End Sub
我的代码:从8:00:00开始每隔2分钟Text1.Text显示OK
Dim ks As Date, XZ As Date
Private Sub Timer1_Timer()
Dim k
ks = "8:00:00"
XZ = Time
k = 2 * (Fix((60 * (Format(CDate(XZ - ks), "h")) + Format(CDate(XZ - ks), "n")) / 2) + 1)
If Time = DateAdd("N", k, ks) Then
Text1.Text = "OK"
End If
End Sub
解决方案 »
- GDI占用内存问题
- matlab里的二维数组怎么被VB调用
- 怎么在WORD里面加入一个运行的程序?
- 请问 Outlook.MailItem对象项目Mymail1 有哪个属性说明邮件正在发送呢??
- 关于用mcisendstring播放VCD格式文件时的问题
- listview,listbox,datalist各有什么特点,有什么相似点与不同点,通常各自又做什么用途呢?
- 关于ado的问题!请各位大侠帮助!
- 请教VB6的OPEN语句在VS 2008中的变化
- WebBrowser radio控件怎么自动选择?还有控件数字名称怎么处理?
- 如何控制另一个可执行程序的窗口的行为?
- EXCEL2003
- NEW的作用
If CLng(Format(Time, "HH")) > 20 Then
lngTimeCount = lngTimeCount + 1
If lngTimeCount = 2 Then
Text1.Text = "OK"
lngTimeCount = 0
End If
End If
End SubTimer1的Interval设置成1分钟一次即可
Private lngTimeCount As LongPrivate Sub Command1_Click()
Timer1.Interval = 60000
End SubPrivate Sub Timer1_Timer()
If CLng(Format(Time, "HH")) > 8 Then
lngTimeCount = lngTimeCount + 1
If lngTimeCount = 2 Then
' Text1.Text = "OK"
lngTimeCount = 0
End If
End If
End Sub
XZ = Timer
If ks = 0 Then ks = XZ
If XZ - ks = 120 Then
ks = XZ
Text1.Text = "OK"
End If
End Sub'将timer1的Interval设置为小于1000即可
Dim ks As Date, XZ As DatePrivate Sub Timer1_Timer()
If ks = "0:00:00" Then ks = "8:00:00"
XZ = Time
If DateDiff("s", ks, XZ) Mod 120 = 0 Then
ks = XZ
Text1.Text = "OK"
End If
End Sub
'将timer1的Interval设置为1000即可