VB怎么倒计时间?

来源:百度知道 编辑:UC知道 时间:2024/05/31 18:00:53
怎么显示到计时?比如倒计时30秒,怎么写?
倒计时过后,想触发单击窗体事件,又怎么写,谢谢大家~~
分不多~

用Timer对象就可以了
Label2.Caption = 30
Timer1.Interval = 1000

Private Sub Timer1_Timer()
Label2.Caption = Val(Label2.Caption) - 1
If Label2.Caption = 0 Then
MsgBox "时间到"
Timer1.Enabled = False
End If
End Sub

设置一个Timer一个Label
private sub form_load()
Timer1.interval=1000
label1.caption=30
end sub

private sub timer1_timer()
label1.caption=label1.caption-1
if label1.caption<=0 then
timer1=false
call form_click
end if
end sub

Dim cou As Long

Private Sub Form_Click()
MsgBox "click form"
End Sub

Private Sub Timer1_Timer()
cou = cou - 1
Me.Caption = CStr(cou)
If cou = 0 Then
Timer1.Enabled = False
Form_Click
End If
End Sub

Private Sub 开始倒计时_Click()
cou = 30
Timer1.Interval = 1000
Ti