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

Operational Situational Summary - Ukraine 2 March

From a glance at the map and the news reports, it appears that the Russian advance has been very slow or even checked. However, a deeper look shows the situation has worsened significantly for Ukraine. That this happened as per my expectation in the past few posts makes me feel worse. In the North, the Russian forces have already encircled Chernihiv in the past couple of days. This is not yet fully updated on this map. The two strong armored spearheads from Konotop (which had also fallen) are currently holding in Pryluky and Nizhyn. The Chernihiv garrison probably has a day or two before the Russians reach Kozelets. Then any breakout attempt to Kyiv will become extremely difficult and will likely result in very heavy losses. It is to be expected that this city too, will fall soon without affecting the battle of Kyiv. This is bad for Ukraine. Now that the International Community has rallied for Ukraine, the previous fears of Russia dealing with breakaway republics in the East should be ...

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...

Growing up

Time affects everything and everyone We all grow up. After college, friends go places, to different states and far away countries. You get less and less time. Some go for higher studies, again, in other states. Parents get older. Then friends start getting married. First it’s usually the girls. One by one, your crushes tie the knot. You dismiss it, you are still young. Then your guy friends start getting married too. Your circle shrinks. In the end you look around. All you are left with are ideological nutjobs, immature imbeciles, idealistic crazies, bohemian hippies, or other misfits. Do you really belong here? Okay, that was too harsh. But you think. You say to yourself, ‘ dil to baccha hai jee ’.  Okay, fair enough. And then... Then, you see a growing pot belly. Something you always despised. Your dad had one (he still does). After taking a shower, you look at the mirror. You are losing hair. You search on Amazon for hair growing products - it is too much of a hassle. Hair trans...