how can i exit an active sub when timer is stopped. RRS feed

  • Question

  • I have a button and a timer, I want to:
    when timer is stopped, exit button click event.
    I have no idea how to do it

    timer code is:

    Private Sub Tmr_Tick(sender As Object, e As EventArgs) Handles Tmr.Tick
            If timeLeft > 0 Then
                timeLeft -= 1
                TextBox2.Text = timeLeft & " seconds"
                TextBox2.Text = "Time's up!"
            End If
        End Sub

    button code is:

    Private Sub Btnrät_Click(sender As Object, e As EventArgs) Handles Btnrät.Click
            If Lbltecen.Text = "+" Then
            ElseIf Lbltecen.Text = "-" Then
            ElseIf Lbltecen.Text = "x" Then
            ElseIf Lbltecen.Text = "÷" Then
            ElseIf Lbltecen.Text = "plus" Then
            End If
        End Sub

    Saturday, February 1, 2020 1:31 PM

All replies

  • Let's say the button name is ExitButton, use ExitButton.PerformClick()

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    profile for Karen Payne on Stack Exchange

    Saturday, February 1, 2020 1:34 PM
  • Hi,

    Have you solved this problem now?

    I think the above reply can provide you with a solution, have you tried it?

    If so, hope you can close this thread by marking the reply as answer as this will help others looking for the same or similar issues down the road.

    Best Regards,


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Monday, February 3, 2020 9:44 AM