第1部分:应用场景
咳咳,也是华仔之前提到的,
通过开发一个小应用来达到网站倒计时搜集网络视频的目的。
所以不得不用到倒计时代码,
其实也就是用了两个timer控件交替进行实现的。
第2部分:解决方法
这里废话不多说,
直接上代码:
'窗体载入,数据初始化 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Label1.Text = "01" & ":" & "00" & ":" & "00" Timer1.Enabled = True Timer1.Interval = 1000 Button1.Text = "暂停" End Sub 'timer1倒计时结束,关闭并调用timer2 Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Dim time = CDate(Label1.Text) time = time.AddMilliseconds(-1) Label1.Text = time Dim shijian = Split(Label1.Text, ":") If shijian(0) = 0 And shijian(1) = 0 And shijian(2) = 0 Then Label1.Text = "01" & ":" & "00" & ":" & "00" WebBrowser7.Refresh() Timer2.Enabled = True Timer2.Interval = 1000 Timer1.Enabled = False End If End Sub 'timer2倒计时结束,关闭并调用timer1 Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick Dim i = 0 i += 1 If i = 120 Then Timer1.Enabled = True Timer1.Interval = 1000 Timer2.Enabled = False End If End Sub
希望能够帮到大家!
也希望同学们有什么批评建议,
可以给华仔反馈哟
© 版权声明
THE END
暂无评论内容