不一定对 Dim i Const a = 2400 Private Sub Command1_Click() Timer1.Enabled = True End SubPrivate Sub Form_Load() Timer1.Enabled = False Timer1.Interval = 1000 i = 0 End SubPrivate Sub Timer1_Timer() s = a - i x = s Mod 60 If Len(x) = 1 Then x = "0" & x y = s \ 60 If Len(y) = 1 Then x = "0" & y 'MsgBox Y Text1.Text = y & ":" & x i = i + 1 End Sub
最后加一句 If x=0 and y=0 then Exit sub
Dim Second As Integer Dim Minute As Integer Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick Me.Timer1.Interval = 1000 Second = Second - 1 If Second = 0 Then Minute = Minute - 1 Me.Label1.Text = Minute Second = 60 End If If Minute = -1 Then Me.Timer1.Stop() Me.Label1.Text = "" Me.Label3.Text = "" MsgBox("计时时间到!") End If Me.Label3.Text = Me.Second End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Minute = Me.TextBox1.Text.ToString.Trim - 1 Second = 60 Me.Label1.Text = Minute Me.Label3.Text = Second Me.Timer1.Start() End Sub '加三个label一个显示分钟 ,一个显示秒,一个显示":",一个textbox输入倒计时多久,上面的程序支持整数如40,一个button开始按钮,还有一个时钟控件
Dim i
Const a = 2400
Private Sub Command1_Click()
Timer1.Enabled = True
End SubPrivate Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 1000
i = 0
End SubPrivate Sub Timer1_Timer()
s = a - i
x = s Mod 60
If Len(x) = 1 Then x = "0" & x
y = s \ 60
If Len(y) = 1 Then x = "0" & y
'MsgBox Y
Text1.Text = y & ":" & x
i = i + 1
End Sub
Dim Minute As Integer
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Me.Timer1.Interval = 1000
Second = Second - 1
If Second = 0 Then
Minute = Minute - 1
Me.Label1.Text = Minute
Second = 60
End If
If Minute = -1 Then
Me.Timer1.Stop()
Me.Label1.Text = ""
Me.Label3.Text = ""
MsgBox("计时时间到!")
End If
Me.Label3.Text = Me.Second
End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Minute = Me.TextBox1.Text.ToString.Trim - 1
Second = 60
Me.Label1.Text = Minute
Me.Label3.Text = Second
Me.Timer1.Start()
End Sub
'加三个label一个显示分钟 ,一个显示秒,一个显示":",一个textbox输入倒计时多久,上面的程序支持整数如40,一个button开始按钮,还有一个时钟控件