注册 登录
编程论坛 VB.NET论坛

[求助]关于倒计时的问题

hemingsheng 发布于 2007-10-25 09:24, 1947 次点击
按下暂停按钮当前倒计时暂停 按下继续按钮 当前倒计时继续开始而不是又从头开始倒计时 请问怎么做?
有没有让timer控件暂停的方法??
3 回复
#2
hezhifang2007-10-27 18:23

Public Class Form1

Public total As Integer
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
total = Val(InputBox("请输入倒记时数", "倒记时输入", "0"))
Button1.Enabled = True
Label2.Text = total
Timer1.Enabled = True

End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

If Label2.Text = 0 Then
Else
Label2.Text = Val(Label2.Text - 1)
End If
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Static a As Integer = 0 'a是一个标记数,主要实现一个按钮,两个作用

If a = 0 Then
Timer1.Enabled = False
Button1.Text = "继续"
a += 1
Else
Timer1.Enabled = True
Button1.Text = "暂停"
a = 0
End If
End Sub
End Class

只有本站会员才能查看附件,请 登录

#3
hemingsheng2007-10-27 20:03

非常感谢
!!

#4
ghb2008-07-01 15:33
我用VB.NET2003的怎么做奥运会倒计时啊
你发的VB6我运行不了
1