Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net Visual Basic-在00:00时重置_Vb.net_Date_Reset - Fatal编程技术网

Vb.net Visual Basic-在00:00时重置

Vb.net Visual Basic-在00:00时重置,vb.net,date,reset,Vb.net,Date,Reset,我有一个关于每晚同时重置标签的问题 我的意思是: 1.启动程序时,my label.text=750 每次有人点击一个按钮,标签文本就会减少1左右 750 749 748等 但现在我希望每天00:00标签的文本重置为750 这有可能吗?贾维德·阿克兰的评论是正确的——如果程序不是在午夜运行,这一切都无关紧要 但是,对于你实际要求的——在午夜重置计数——考虑在你的项目中添加一个定时器。你真的只需要定时器每天点击一次(午夜): 您还需要在Form_Load中添加对SetInterval的调用(或者无

我有一个关于每晚同时重置标签的问题

我的意思是: 1.启动程序时,my label.text=750 每次有人点击一个按钮,标签文本就会减少1左右 750 749 748等

但现在我希望每天00:00标签的文本重置为750


这有可能吗?

贾维德·阿克兰的评论是正确的——如果程序不是在午夜运行,这一切都无关紧要

但是,对于你实际要求的——在午夜重置计数——考虑在你的项目中添加一个定时器。你真的只需要定时器每天点击一次(午夜):

您还需要在Form_Load中添加对SetInterval的调用(或者无论您的程序初始化是什么),以设置第一个间隔



在一个几乎完全不相关的注释中,有人知道为什么Date类有一个addMissicles函数,而Microsoft.VisualBasic.DateInterval(因此DateDiff函数)没有毫秒吗?它是非对称的。

你的应用程序会全天候运行吗?不会,但我想可能会制作一些保存一些设置的东西,如果应用程序加载,它会检查00:00是否已经过了。如果你的应用程序没有连续运行,你必须将一些数据保存在
文件或
数据库中,我没有数据库方面的经验,你能帮我一点忙吗?
Private Sub SetInterval()
    ' Calculate how many milliseconds until the timer ticks again:
    ' Start by calculating the number of seconds between now and tomorrow.
    ' Multiply by 1000, then add 50 more -- this is to make sure that the
    ' timer runs 1/50 of a second AFTER midnight, so that we can
    ' re-calculate the interval again at that time.
    Timer1.Interval = CInt( _
        DateDiff(DateInterval.Second, Now, Today.AddDays(1)) * 1000 + 50)
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Timer1.Tick
    ' Reset the interval, so that we run again tomorrow at midnight.
    SetInterval()

    ' Now, reset your label
    Label1.Text = "750"    ' Or whatever else needs to happen to reset the count
End Sub