大佬,我这有段代码,但是我在关闭窗体的时候,代码仍在运行如何停下来啊?
Private Sub UserForm_Activate() '在激活userform1时开始倒计时,计时结束后,只显示交卷按钮
st = Now()
t = CDate("00:40:00") '以下代码我没看懂,抄的网络,大概意思能明白
Label_时间.Caption = t
Do
DoEvents
If DateDiff("s", st, Now()) = 1 Then
st = Now()
t = DateAdd("s", -1, t)
If Minute(t) = 0 And Second(t) = 0 Then Exit Do
Label_时间.Caption = t
End If
Loop
If Label_时间.Caption = "0:00:01" Then
CommandButton1.Visible = False
CommandButton2.Visible = False
CommandButton3.Visible = True
End If
End Sub
Private Sub UserForm_Activate() '在激活userform1时开始倒计时,计时结束后,只显示交卷按钮
st = Now()
t = CDate("00:40:00") '以下代码我没看懂,抄的网络,大概意思能明白
Label_时间.Caption = t
Do
DoEvents
If DateDiff("s", st, Now()) = 1 Then
st = Now()
t = DateAdd("s", -1, t)
If Minute(t) = 0 And Second(t) = 0 Then Exit Do
Label_时间.Caption = t
End If
Loop
If Label_时间.Caption = "0:00:01" Then
CommandButton1.Visible = False
CommandButton2.Visible = False
CommandButton3.Visible = True
End If
End Sub