如何在标签中自动重复计数器并在达到最大计数时调用事件。

How to auto repeat counter in label and call an event when reach maximum count.

我想制作一个计数器直到 5 的程序,当达到 5 时它会自动点击一个按钮并且每次达到 5 时都必须从 0 - 5 重新计数。

下面是我在计时器点击中的代码。

    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

结束Class

here is my solution to my question:

当计时器滴答时,我会自动递增我的标签 1-5,当它达到 5 时,它会 return 到 0 并再次计数 1-5。然后重复。然后可以在达到 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