[英]How to auto repeat counter in label and call an event when reach maximum count.
I want to make a program that has a counter until 5 and when reach 5 it will auto click a button and must count back from 0 - 5 again and again every time reach 5.我想制作一个程序,它有一个直到 5 的计数器,当达到 5 时,它会自动单击一个按钮,并且每次达到 5 时都必须从 0 - 5 一次又一次地倒数。
below is my code in timer click.下面是我的计时器点击代码。
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer2.Tick
Dim ts As TimeSpan = TargetDT.Subtract(DateTime.Now)
If ts.TotalMilliseconds > 0 Then
lblTime2.Text = ts.ToString("ss")
Else
lblTime2.Text = "00"
Timer2.Stop()
btnRefresh.PerformClick()
End If
End Sub
Private Sub btnRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRefresh.Click
messagebox.show 'me dot click'
End Sub
End Class结束类
here is my solution to my question:
when the timer tick i auto increment my label 1- 5 and when it reach 5 it will return to 0 and count again 1 - 5. and repeat.当计时器滴答时,我会自动增加我的标签 1-5,当它达到 5 时,它将返回 0 并再次计数 1-5。并重复。 then can do something after reach 0. hope can help然后可以在达到 0 后做一些事情。希望可以帮助
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label1.Text = Label1.Text + 1
If Label1.Text = "5" Then
Label1.Text = 0
btnRefresh.PerformClick()
End If
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.