timer=false并没有立刻退出timer过程

timer=false并没有立刻退出timer过程,第1张

'设定个全局变量
timerFlag=true
'在计时器时判定timerFlag为真时才计时!
if timerFlag then
'计时开始
if '退出条件 then exit sub
end if
'如果你想停止计时器,只需要把
if '退出条件 then timerFlag=false
'就行了! 想开始就设为true

Dim i As Integer
Dim a As Integer
Dim b As Integer
Private Sub Label1_Click()
Label1Caption = Time
Timer1Enabled = True
End Sub
Private Sub Label2_Click()
Label2Caption = Time
Timer1Enabled = False
End Sub
Private Sub Timer1_Timer()
i = i + 1
If i >= 60 Then
a = a + 1
i = 0
End If
If a >= 60 Then
b = b + 1
End If
Label3Caption = b & ":" & a & ":" & i
End Sub
注:timer1enable=false
timer1interval=1000

最简单的办法是做个菜单,菜单可以设置快捷键,剩下的你懂得
也可以这样:
Private
Sub
Form_KeyDown(KeyCode
As
Integer,
Shift
As
Integer)
If
KeyCode
=
vbKeyA
Then
End
End
Sub
Private
Sub
Form_Load()
MeKeyPreview
=
True
End
Sub
'按a键直接退出程序


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/13347525.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-07-19
下一篇 2023-07-19

发表评论

登录后才能评论

评论列表(0条)

保存