倒数计时器如何动态增加更多时间-我希望能够在计时器滴答时通过单击按钮来增加15秒,这是代码 [英] Count Down Timer how to dynamically add more time - I want to be able to add 15 secs with a button click while the timer is ticking down here is the code

查看:148
本文介绍了倒数计时器如何动态增加更多时间-我希望能够在计时器滴答时通过单击按钮来增加15秒,这是代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Public TimerClockSecs As Integer = 10 'Seconds that the ClockStart() Function Uses
    Public alarmTime As Date ' Variable for tmr_Clock() Function
    Public remainingTime As TimeSpan 'Variable for Clock() Function





 Private Sub tmr_Clock_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmr_Clock.Tick
        If alarmTime < Date.Now Then
            Me.tmr_Clock.Enabled = False
        Else
            remainingTime = Me.alarmTime.Subtract(Date.Now)
            Me.lbl_TimerClock.Text = String.Format("{0}:{1:d2}", _
                                          remainingTime.Minutes, _
                                         remainingTime.Seconds)
End Sub





Private Sub ClockStart()
       lbl_TimerClock.Text = TimerClockTime
       Me.alarmTime = Date.Now.AddSeconds(TimerClockSecs)
       tmr_Clock.Enabled = True
   End Sub

推荐答案

我终于弄明白了grrr哈哈...在我的按钮点击事件中,我添加了此内容


I figured it out finally grrr lol...in my button click event I add this


Me.alarmTime = Date.Now.AddSeconds(15) + remainingTime


这篇关于倒数计时器如何动态增加更多时间-我希望能够在计时器滴答时通过单击按钮来增加15秒,这是代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆