VB写了个TIMER但是是30分钟执行一次60分钟执行一次每次的执行不一样,到了60又返回下一个30这样循环执行.
Private Sub Timer1_Timer()
'设置时钟为30000
Static n As Integer
n = n + 1
If n Mod 60 = 0 Then '30分钟
Label1.Caption = "温馨提示:30分钟"
Form1.Visible = True
SetWindowPos Me.hWnd, -1, 0, 0, 0, 0, 2 Or 1
Timer2.Enabled = True
End If
If n Mod 120 = 0 Then '60分钟
Label1.Caption = "温馨提示:60分钟"
Form1.Visible = True
SetWindowPos Me.hWnd, -1, 0, 0, 0, 0, 2 Or 1
Timer2.Enabled = True
End If
End Sub
但是到下个60的话好像程序就不知道自己干什么了哦,有可能还以为是30呢.
追问:这样写可以但是有个问题就是在显示60的时候30的画面会跳一下然后才显示60分钟.
答案:'一个定时器Timer1就可以了
Dim n%
Private Sub Timer1_Timer()
'设置时钟为30000
Static n As Integer
n = n + 1
If n = 120 Then '60分钟
Label1.Caption = "温馨提示:60分钟"
Form1.Visible = True
SetWindowPos Me.hWnd, -1, 0, 0, 0, 0, 2 Or 1
n = 0 '60分钟后清零
ElseIf n = 60 Then '30分钟
Label1.Caption = "温馨提示:30分钟"
Form1.Visible = True
SetWindowPos Me.hWnd, -1, 0, 0, 0, 0, 2 Or 1
End If
End Sub
上一个:VB6.0在窗体里面加的背景图片很大的时候,如何让图片去根据窗体的大小来显示?
下一个:vb中scale full是什么意思啊,小弟求教各位大侠啦