VB.NET Timer and Circular ProgressBar - START,STOP,RESUME,RESET


Here we see a timer example with a custom circular progressbar.We see how to start the timer,stop it,resume it as well as reset on button click.

Take note we are using a third-party UI skin library that gives us the nice and easy to modify custom progressbar as well as other UI components.The library is located at HazelDev.com.

Its free and open source.There are various UI skins like ambience and skin,just download the ,extract it and copy the class file e.g ambience.vb,italk.vb etc,then right click your project and add it over there.Then rebuild your project.Then in you designer you shall have that theme's components.Add them to your project then that's it.

Public Class Form1

    Dim progress As Integer = 0

    'RSETE

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        'INCREMENT OUR PROGRESS
        progress += 1

        ' CHECK IF IT REACHES 100 AND STOP
        If (progress >= 100) Then
            Timer1.Enabled = False
            Timer1.Stop()
            startBtn.Text = "Start"
        End If

        'OTHERWISE CONTINUE UPDATINGH
        ProgressBar1.Value = progress
        p.Value = progress

    End Sub

    Private Sub startBtn_Click_1(sender As Object, e As EventArgs) Handles startBtn.Click
        ProgressBar1.Maximum = 100
        If progress < 100 Then
        Else
            progress = 0
        End If

        Timer1.Enabled = True
        Timer1.Interval = 50
    End Sub

    Private Sub stopBtn_Click_1(sender As Object, e As EventArgs) Handles stopBtn.Click
        'STOP
        Timer1.Stop()

        ' UPDATE START BTN TXT IF PROGRESS IS <100 AND >0
        If progress > 0 And progress < 100 Then
            startBtn.Text = "Resume"
        End If
    End Sub

    Private Sub resetBtn_Click(sender As Object, e As EventArgs) Handles resetBtn.Click
        progress = 0
        ProgressBar1.Value = 0
        p.Value = 0
        startBtn.Text = "Start"
    End Sub
End Class

Best Regards.

How do You Feel after reading this?

According to scientists, we humans have 8 primary innate emotions: joy, acceptance, fear, surprise, sadness, disgust, anger, and anticipation. Feel free to tell us how you feel about this article using these emotes or via the comment section. This feedback helps us gauge our progress.

Help me Grow.

I set myself some growth ambitions I desire to achieve by this year's end regarding this website and my youtube channel. Am halfway. Help me reach them by:




Recommendations


What do You Think


Previous Post Next Post