如何在vb.net中使用计时器

编程入门 行业动态 更新时间:2024-10-11 17:27:13
本文介绍了如何在vb中使用计时器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

喜。我需要在20秒后将lable1名称更改为Ready,当我点击button1时。我尝试使用timer.but not success.please给我简单的代码或任何advise.please.im使用vb 这是我的coad private sub timer1_timer() label1.text =loading end sub 我在解决方案探索中启用我的计时器,它有1000个间隔 谢谢....

hi. i need change lable1 name as "Ready" after 20 second when i click on the button1. im tryed using timer.but not success.please give me simple code or any advise.please.im using vb this is my coad private sub timer1_timer() label1.text="loading" end sub im enable my timer in solution explore and it have 1000 interval thanks you....

推荐答案

使用VB查找下面的答案(我已根据Shahin Khorshidnia更新了我的代码) 请创建标签(将名称设为lblText)& 按钮(设置名称为btClick) Hi, Find the answer below using VB (I have updated my code as per Shahin Khorshidnia) Please create label (Set name as lblText) & Button (Set name as btClick) Public Class TimerApplication Private Shared WithEvents myTimer As New System.Windows.Forms.Timer() Private Shared alarmCounter As Integer = 1 Private Shared exitFlag As Boolean = False 'This is the method to run when the timer is raised. Private Shared Sub TimerEventProcessor(ByVal myObject As Object, _ ByVal myEventArgs As EventArgs) _ Handles myTimer.Tick myTimer.Stop() exitFlag = True End Sub 'Button click event Private Sub btClick_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btClick.Click lblText.Text = "" myTimer.Interval = 10000 myTimer.Start() ' Runs the timer, and raises the event. While exitFlag = False ' Processes all the events in the queue. Application.DoEvents() End While 'Print the lable value after 10 seconds lblText.Text = "Ready" End Sub End Class

你需要开始你的Timer使用代码Timer.Start()。查看此处 [ ^ ]。 You need to start your Timer by using code Timer.Start(). Check here[^].

更多推荐

如何在vb.net中使用计时器

本文发布于:2023-11-27 16:29:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1638751.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:计时器   如何在   vb   net

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!