有没有让timer控件暂停的方法??
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