这段vb程序怎么实现不了呢?10分

来源:百度知道 编辑:UC知道 时间:2024/07/02 01:17:16
Private Sub Form_Load()
Timer1.Interval = 1000
End Sub

Private Sub Timer1_Timer()

Cls
Dim tt
t = CDate(Time)
tt = DateDiff("n", t, "1:00: 00")
If tt <= 8 And tt >= 1 Then
MsgBox "888666!:)"
End If
End Sub

我想让这段代码实现:当系统时间在2:00到9:00之间,就跳出“888666”这个框
为什么这段代码不能用呢?
错在哪里?
谢谢各位拉

我帮您修改了一下,可以运行了
Private Sub Form_Load()
Timer1.Interval = 1000
End Sub

Private Sub Timer1_Timer()

Cls
Dim tt
t = CDate(Time)
tt = DateDiff("h", "1:00: 00", t)
If tt <= 8 And tt >= 1 Then
MsgBox "888666!:)"
End If
End Sub
您的错误有2
1:DateDiff在比较时间的时候,要用“h”而不是“n”
2:t应该放在最后一个参数的位置上,否则出来的结果是负数