Skip to main content

Another Timer Demo

What this done is simple.

When I click on a Button the progress bar will show for 5 seconds and then some other work can be done. Well, here it is.

'Simple Timer demo by Sarthak Ganguly
'Released under GPLv3 Share Alike License.
 
Public Class MainFrm
    'Say 2 seconds is the default timeout
    'You can change it from here or make it a
    'property with Get and Set statements
    'you can increase it to 3,4,5... seconds
    Dim timeLimit As Integer = 50 * 100 '(milliseconds)
    Dim temp As Integer = 0
    Private Sub clickBUT_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
        Handles clickBUT.Click
        'Start the timer
        aTmr.Enabled = True
    End Sub
    Private Sub aTmr_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) _
        Handles aTmr.Tick
        'The timer ticks :) with Step 100ms
        progBar.Value += OneStep()
        'Stop the Timer
        temp += 100
        If temp = timeLimit Then
            aTmr.Enabled = False
            temp = 0
            'Add code if you want anything to happen after progressbar
            'reaches maximum value
        End If
    End Sub
    'This is the most important function as it will return the
    'relative unit size of the progress bar
    Private Function OneStep() As Integer
        'One unit returned and converted to nearest Integer
        Return CInt(progBar.Maximum / (timeLimit / 100))
    End Function
End Class

Comments

Popular posts from this blog

Affinity towards attachment

Of late I realize how attached I get to people, places and even things.  This is not just limited to stuff that I care about, but also mundane things that I don’t really generally much about either.  On most days, I am not even conscious about it. But when I am, I find it increasingly weird.  This hits different than hoarding though. Garbage is something I can easily get rid off. It is just that the definition of what I consider garbage is limited. More worryingly, I find accepting stuff (or God forbid, people) that I considered a treasure can now safely be put in the bin extremely difficult. This was always the case to an extent, it is not new. Just that at my age I just have come to this self realization on my own.  What do I need to do about it? I am not sure to be honest. On one hand, I agree, obsessively being attached to anything or anyone is not healthy. But, at the same time, Life still works, relatively okay. Of course, inanimate objects are better in this r...

Saraswati Puja and Valentine's Day Coincide

I used to hear this a lot - for Bengalis (Bengali Hindus), Saraswati Pujo is equivalent to the Valentine's Day . Girls would wear yellow sarees and braid their hair, while guys will be wearing yellow punjabees and white dhoti or pajama.  This time on Feb 14, 2024, they fell on the same day. Woke up pretty early in the morning, showered, wore the dhuti and uttiyo and did Saraswati Puja. Most of the mantras I have got by heart now. After the pushpanjali , I was done and we (my mother and I) could then break our fast with the Mahaprasad . Took a day off for the day, but still joined for a quick catchup call.  This is how she looks like. There is a bit of a history here. Usually, Hindus get the vigraha from the shop every year, worship and then do visarjan (immersion) in a river or pond. However, she is with us since I was in class IX. When I was in Standard X, my grandmother had died. As part of the souch (relatively inauspicious greiving period), we could not get a new vigra...

Getting back to making stuff

I was off for a while. I mean, I was not. I painted an old shoecase that now looks a gorgeous white cupboard. I fixed my bicycle.  But beyond this, I did not do much beyond what my work paid me to do. So here I am, about to touch a new year of my life - and I am itching to get back into the habit of writing again.  Not just writing stuff here, but also making applications or music.  In fact, after a very long time I feel like sketching again. I think I am going to sketch my wife. Or may be finish my ex wife's sketch. I dunno. But I am gonna get started with a pencil tomorrow. Thanks to chatgpt, I have restarted my application brainstorming and dusted my old Github repos.  I think this is going to be a good run this time.