使用VB的倒数计时器 [英] Countdown Timer using VB

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

问题描述

大家好.如何使用计时器进行倒数计时?我需要的时间是40分钟,时间结束后,会出现一个弹出窗口,显示结束".由于某些原因,我不想使用消息框.

Hello all. How can I make a countdown using Timer? The time I need is 40 minutes and after the time is over, a popup appears said "over". i dont wanna use message box because of certain reason.

thanks for any help.

推荐答案

如果这是Ajax/web,则可能无法.

通常发生的情况是,当访问页面时,您的应用程序将启动,生成页面并被销毁(这是一个过分简化的过程,但为此目的足够接近).

因此,您在服务器端代码中创建的任何计时器也将被销毁.

最好的方法是在客户端的Javascript中设置计时器并使用Javascript Alert函数.

如果这是WinForms,那么很简单:

在您的表单中创建一个Timer,将Interval设置为40 * 60 * 1000并为其提供Tick事件的处理程序.
事件发生时,请执行告诉用户的操作.
If this is Ajax / web, then you probably can''t.

What normally happens is that when a page is visited, your app is started, generates the page, and is destroyed (That is an oversimplification, but it''s close enough for this).

So any timer you create in your server side code will be destroyed as well.

The best way to do this, is to set a timer in the Javascript on the client side and use the Javascript Alert function.

If this is WinForms, then it is easy:

Create a Timer in your form, set the Interval to 40*60*1000 and give it a handler for the Tick event.
When the event occurs, do what you need to to tell the user.


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

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