倒计时vb代码

2024-12-26 10:23:49
推荐回答(5个)
回答1:

十秒倒计时程序代码:
Dim N As Integer

Private Sub Form_Load()
N = 10
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
N = N - 1
If N > 0 Then
Label1.Caption = N
Else
Label1.Caption = "时间到"
Timer1.Enabled = False
End If
End Sub

回答2:

Dim x As Integer
Private Sub Form_Load()
Timer1.Enabled = True
Timer1.Interval = 1000
x = Val(InputBox("输入倒计时秒数"))
Me.Caption = x
End Sub

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

一个timer控件足以

回答3:

建立一个时钟timer控件,设置属性:1000
dim t as integer
Private Sub form1_load()
t=10
end sub
Private Sub Timer1_Timer()
t = t - 1
If t > 0 Then
Timer1.enable=false
End If
End Sub

回答4:

Dim N As Integer
Private Sub Form_Load()
N = 60
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
N = N - 1
If N > 0 Then
Label1.Caption = N
Else
Label1.Caption = "时间到"
Timer1.Enabled = False
End If
End Sub
一分钟计时

回答5:

在上面输入10这个字
然后label1.caption=(label1.caption)-1
然后把计时器 interval改成1000 就可以自动倒计时了