VB.net中如何用timer控件编出一个简单的倒计时器?
要求按正常的时间一秒一秒的减,倒计时结束时有提示。请高手指点,回答尽量详细点,有代码最好!谢谢…...
要求按正常的时间一秒一秒的减,倒计时结束时有提示。请高手指点,回答尽量详细点,有代码最好!谢谢…
展开
4个回答
展开全部
Dim tCount As Integer '用来计数
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
tCount = 10
Timer1.Interval = 1000 '每秒执行一次
Timer1.Enabled = True
End
Sub
Private Sub
Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
tCount -= 1
If tCount = 0 Then
MessageBox.Show("时间到")
Timer1.Enabled = False
End If
End
Sub
2013-06-30
展开全部
Public Class Form1
Dim tCount As Integer '用来计数
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
tCount = 10
Timer1.Interval = 1000 '每秒执行一次
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
tCount -= 1
If tCount = 0 Then
MsgBox("时间到")
Timer1.Enabled = False
End If
End Sub
End Class
Dim tCount As Integer '用来计数
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
tCount = 10
Timer1.Interval = 1000 '每秒执行一次
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
tCount -= 1
If tCount = 0 Then
MsgBox("时间到")
Timer1.Enabled = False
End If
End Sub
End Class
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-06-30
展开全部
全局变量
每次--就对了
每次--就对了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-06-30
展开全部
用Timer控件吧,设置1秒执行1次。然后直接在Timer中写代码,将全全局的值来 减减1,如果值为0,则停止Timer 跳出提示框
以下示例:
int Tatal = 100;
Timer.Inveral = 1000;
Timer_()
{
if ( Tatal == 0)
{
MessageBox.Show("完成!");
Timer.Stop();
}
else
{
Tatal --;
}
}
以下示例:
int Tatal = 100;
Timer.Inveral = 1000;
Timer_()
{
if ( Tatal == 0)
{
MessageBox.Show("完成!");
Timer.Stop();
}
else
{
Tatal --;
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询