我如何快速使用计时器 [英] how can i use timer fastly plz

查看:107
本文介绍了我如何快速使用计时器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在登录按钮中使用计时器,我希望用户等待1分钟,直到他进入主页后才能使用它????

i want to use timer in the login button i want the user to wait for 1 minute befor he enter the main page how can i use it???

推荐答案

尝试使用此


Try with this


Dim dt As Date

   Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click

       dt = DateTime.Now()
       dt = DateAdd(DateInterval.Minute, 1, DateTime.Now())

       Timer1.Enabled = True

   End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If DateTime.Now() > dt Then
            Form2.Show()
            Timer1.Enabled = False
            Exit Sub
        End If
    End Sub


这是其中之一计时器System.Windows.Forms.Timer足够的罕见情况:
http://msdn.microsoft.com/en-us/library/system. windows.forms.timer.aspx [ ^ ].

不要忘记设置计时器的Interval = 1000; P.S. Vijay没有显示它.

我需要解释.此计时器是最糟糕但最简单的用于Forms的计时器.与其他两个计时器类不同,它的准确性非常差,如果您需要周期性的感觉,而忘了更严格的要求,那是不可接受的.但是出于您的目的,这已经足够了.

—SA
This is one of the rare cases when the timer System.Windows.Forms.Timer is adequate:
http://msdn.microsoft.com/en-us/library/system.windows.forms.timer.aspx[^].

Don''t forget to setup timer''s Interval = 1000; P.S.Vijay did not show it.

I need to explain. This timer is the worst but simplest to the use with Forms. Unlike two other timer classes, it has very bad accuracy, not acceptable if you need the sense of something periodic, forget about more serious requirements. But for your purpose it''s good enough.

—SA


使用此..

Use this..

Thread.Sleep(20000);


这篇关于我如何快速使用计时器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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