Skip to main content

Make a Splash!

 

I was sitting at home, when suddenly I got a request to write a splash form. So I wrote this. It  is fairly simple to implement.

Just add a Windows Form to a new Visual Basic Project.

Add a Timer Control to the Form, named ‘theTimer’

Now add two labels, one for a statement, other to show the countdown. I have named them lbl1 and tmrLabel.

Go to its code of the Form and copy and paste this down. I have assumed the form name to be ‘MainFrm’. Run it and you are good to go. All with a fade in and fade out animation. Simple yet efficient. And to the friend who requested, it was a pleasure. :)

'''<summary>
''' A simple Splash Screen with basic fade in and fade out animation
''' A Program by Sarthak Ganguly
''' </summary>
''' Released under GPLv3 License
Public Class MainFrm

   'Declaring an Enum with form status
    Enum formStatus
        formOpening
        formShowing
        formClosing
    End Enum


    Dim _formStatus As formStatus = formStatus.formOpening
  
'You can select the animation speed here( fade in and fade out)
    Dim animationSpeed As Double = 0.1
 
  'stayOn is a counter variable
    Dim stayOn As Integer = 0
  
'limit is the time duration for which the form is to remain open
    'Here limit is 30 seconds
    Dim limit As Integer = 300

    'The form closing Event is essential to close the form when the
    'fades out completely, that is when the opacity reaches 0
    Private Sub MainFrm_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing

        If Me.Opacity = 0 Then
            theTimer.Dispose()
            Me.Dispose()
        End If

    End Sub

    'The Fade in Animation begins
    Private Sub MainFrm_Load(ByVal sender As Object, _
                             ByVal e As EventArgs) Handles Me.Load
        theTimer.Start()
        _formStatus = formStatus.formOpening

    End Sub

    'The Timer operations are done here
    Private Sub theTimer_Tick(ByVal sender As System.Object, _
                              ByVal e As System.EventArgs) Handles theTimer.Tick

        Try
            If _formStatus = formStatus.formOpening And Me.Opacity < 1 Then
                Me.Opacity += animationSpeed
                If Me.Opacity = 1 Then
                    theTimer.Enabled = False
                    Call ShowForm()
                End If
            ElseIf _formStatus = formStatus.formClosing And Me.Opacity > 0 Then
                Me.Opacity -= animationSpeed
                If Me.Opacity = 0 Then
                    theTimer.Dispose()
                    Me.Dispose()
                End If
            ElseIf _formStatus = formStatus.formShowing Then
                If stayOn < limit Then
                    stayOn += 1
                    tmrLabel.Text = CInt((limit - stayOn) / 10)
                Else
                    theTimer.Enabled = False
                    Call Form_close()
                End If
            Else
                theTimer.Enabled = False
            End If
        Catch ex As Exception
           
'There should not be any error, but still if there is
            'you'll know
            Console.WriteLine(ex.Message)
        End Try

    End Sub

    'Sends the formClosing status to the Timer
    Private Sub Form_close()
        _formStatus = formStatus.formClosing
        theTimer.Start()
    End Sub

    'Allows the timer to show the form for the duration
    'required
    Private Sub ShowForm()

        _formStatus = formStatus.formShowing
        theTimer.Enabled = True
        theTimer.Start()

    End Sub

End Class

You can get the compiled file from here

http://www.wikifortio.com/472019/SplashScreen.zip

I will also post it on sourceforge.net

Popular posts from this blog

Sri Sri & Homosexuality – Another media hit job in the making

Sri Sri Ravi Shankar (henceforth named as Mr. Shankar) is not new to controversy. Not even with topics like homosexuality. What the event wasAt an event in the Jawaharlal Nehru University, Ravi Shankar gave a talk on the occasion of the Nehru Memorial lecture on 13th November, 2017. One among the audience lamented that he was ill-treated since he was known to be a homosexual. Then Mr. Shankar stated that he needed to accept himself as he was and love knew no boundaries. Let’s see and hear what he said…Let’s quote Mr. Shankar verbatim as reported by some of the newspapers.
You treat yourself better, doesn’t matter how others treat you. You don’t think you are sick or something’s wrong with you. If you stand up, nobody can insult you… But if you feel weak and meek, and if you feel bad about yourself, nobody can make you feel better.’ Indian Express reported this in addition as well. Let me quote it directly here as well.
This is your tendency now. Just acknowledge it and accept it, and kno…

Once again in Mirik

This is a guest post by my mother, Lily Ray Gangopadhyay.

Once again in Mirik after 17 years, I felt very nostalgic because when we used to visit this place, my sons were little kids. Mirik is one of my favorite places. In 17 years it has obviously changed a lot, but still it remains sparsely populated,little crowded and a clean place.



Dad striking a pose (caption by Sarthak) Since this hill station is not at very high altitude one can enjoy a very comfortable stay here and the roads are very inviting.The lake is the main attraction of this place, the Buddha monastery,view point are very nice. I was lucky that the weather was so clear that Mt. Kanchenjunga was clearly seen all the time. Just for a restful walking around the lake, sitting on the grass and gazing at the bushes of pine and fur trees and the peaks of the Himalayas, this is my most preferred destination.











How to go>> one can take a taxi , share taxi or bus from NJP station,Siliguri bus stand or Bugdogra airport.It is l…

Salesmen of God

Christian evangelicals are similar to parasites[1]. The similarities are simply astounding. Among all predatory religions, Evangelical Christianity has done, by far, the greatest harm to humankind[2]. Like leeches, the Evangelical sucks the lifeblood of an unchristian society till it descends either into chaos and incessant civil conflict or the relegation of the culture to the pages of history(Bowden, 1985). Even in the 21st century this unashamed activity continues(Bhosle, 2003).[3]
Evangelicals usually have a similar methodology when it comes to proselytization. Like parasites, the target is usually one belonging to the most vulnerable section of society. This does not necessarily mean that they try harvesting only the most down trodden of the society(Kelly, 2001). And most certainly, the objective is never the upliftment of the persons involved. The target groups may, for example, belong to ethnic minorities, refugees (both economic and political), caste groups, the poor and the si…