17
Feb
06

Splash Screen In Visual Basic 6.0

Introduction:

When developing heavy program under any platform you will notice that the program requires a lot of time to start. So what the programmers are doing is that they introduce a screen just before displaying the Main Form which indicates you have started the program and it is loading. So to have modern look and to indicate the user that the program is being loaded we must include Splash Screen in our programs. Designing the Splash Screen is an easy task and requires very little skill.

Designing a Splash Screens

Generally a Splash Screen includes Image/Logo that resembles your program. The Splash Screen is generally displayed on the centre of the Screen. So when you have started designing the Splash Screen. Set the properties of the Splash Screen Form as given below

frmSplashScreen.frm

Properties:

·StartUpPosition: 2 – Centre Screen

·BorderStyle: None

·ShowInTaskbar: False

Now to add a Image/Logo on the Splash Screen drag a Image Control on to the Screen. You may use a PictureBox to do the same. But the Stretching property will not be allowed in PictureBox. Here I used a Image Control and set the properties to…

Image

Properties:

·Picture: Put the path of your Logo/Image

·Stretch: True

Now add the label displaying the name of your program and your identity and assign the colors and fonts as your require. Now the main phase of designing the Splash Screen comes in.

As till now your designing part is completed. Now take the Timer Control and place it on your form. Place it anywhere on your form as it will not be displayed at run time. Decide the time for which you want the user to view your splash screen. If you will be adding a progress bar then close splash screen as soon as the entire program loading process is completed. Set the timer Interval to about 1000 seconds. At the Timer event (i.e Timer1_Timer) of your Timer add the following code which will unload the splash screen and then display the Main Form(Named as frmMain.frm).

Private Sub Timer1_Timer()

Unload Me ‘Unload the Splash Form

frmMain.Show ‘Load the Main Form

End Sub

Also don’t forget to set Splash Screen Form (frmSplashScreen.frm) as your startup form in your project properties. After you have done all with this run your program and watch the difference you get. In later section I will discuss how to add a progress bar effect on the SplashScreen. Do post comments and your designed screens.s


28 Responses to “Splash Screen In Visual Basic 6.0”


  1. 1 Jim Wilson July 3, 2006 at 10:56 pm

    I am interested in how to put a progress bar up on a splash screen and how to let the splash screen know that the main form is finished loading.

  2. 2 Muhammad Aftab September 13, 2006 at 2:12 pm

    it is really help full and easy to understand.

  3. 3 Geethal Fernando November 10, 2006 at 10:37 am

    It worked well.Thanks
    However, in my application the work is done as part of loading the main form so I opened the splash and after one second opened the main form followed by i=unload me
    This did the job

    Private Sub Timer1_Timer()
    frmMain.Show
    Unload Me
    End Sub
    Now I woiuld like the code for progress bar effect on the SplashScreen

  4. 4 Shaili November 19, 2006 at 11:14 pm

    Yes, it works..however I am interested in using a progress bar dynamically showing the status of progress!

  5. 5 Aditya December 29, 2006 at 6:59 pm

    it’s superb….Thanx. I think microsoft should learn….how to put articles on websites…….

  6. 6 Mohammed Hussain February 7, 2007 at 7:43 pm

    Of Great Help!…Thanxs. The way it was explained was superb.

  7. 7 Sandeep Jain February 9, 2007 at 8:28 pm

    Thanks for appreciating my work….

  8. 8 Cody May 8, 2007 at 3:37 am

    Ok I use Visual Studio 2005. I’m not sure how to move the splash screen in the code but you can do it in the poperties box.

  9. 9 Rishipathak Yogesh May 10, 2007 at 12:02 pm

    Thanks
    The way of you coding is very nice.however I am interested in using a progress bar.howing the status of progress!

  10. 10 Abdulrahim Harunani June 5, 2007 at 5:47 pm

    Hello
    I am a student studing programming and would like to know how to animate buttons when a mouse is brought over it.
    animatio like constant colour changing, changing the shape of the button e.t.c
    please assist me as this is a project i am working on and am really stranded with such code.
    thank you.

  11. 11 Sam June 11, 2007 at 4:52 pm

    Very nice indeed,
    I’m looking just like “Adult visuals” for a way to make the position of the splash screen relative as I don’t want it to be at the center of the monitor, settings things to “Manual” wouldn’t help much because if users have got different resolutions, the splash may not be visible at all :(

  12. 12 Sam June 11, 2007 at 7:14 pm

    OK, I think I found it,
    More info: http://vbcity.com/forums/topic.asp?tid=3486

  13. 13 Lemar June 23, 2007 at 1:05 am

    Yow this Bazzel Thanx, I really appreciate it

  14. 14 nitin August 10, 2007 at 4:13 pm

    its works …………….
    thanks a lot………

  15. 15 Amit Rajput August 15, 2007 at 8:59 am

    How one can know the actual time the main form would take to load?And show the actual progress throught progress bar.

  16. 16 Leonardo Alberto October 4, 2007 at 4:28 am

    Very good and simple to understand. Thank you for explication.

  17. 17 James October 14, 2007 at 8:28 pm

    Hi,

    its working perfect. i was reading the article before but tried it now step by step and its great. thank you for the great guidance!

    regards,
    james

  18. 18 Manoj Varghese December 5, 2007 at 4:25 pm

    Thanks it worked well. Will be very helpful if u can specifytutorial for VB to database communication that is taking data from database and sending data to database.

  19. 19 Nilesh B December 14, 2007 at 4:24 pm

    Good work…..very easy to understant…Thank’s a lot

  20. 20 dhaval shah February 11, 2008 at 11:47 am

    i have spalsh screen created & in timer event i have put code:
    splashscreen.hide
    form1.show
    timer event has set time to 1sec.
    now the form1 is displayed in interval of every 1 second
    what should i do??

  21. 21 Sandeep Jain February 12, 2008 at 2:17 am

    Please append the following code to your rimer code…

    timer.enabled=false;

    This line while disable the timer and thus your splash screen won’t show up again and again after every 1sec…

    tc…

  22. 22 tarun February 20, 2008 at 1:11 pm

    I need to know, what is the code for progress bar in Visual Basic 6.0?

  23. 23 LUCY April 5, 2008 at 1:53 pm

    thankyou the code was helpful so lets see about the progress bar!!!

  24. 24 Proshanta May 29, 2008 at 12:34 pm

    Very very helpful. pleas help for progress bar

  25. 25 Proshanta May 29, 2008 at 12:35 pm

    very very helpful

  26. 26 Proshanta May 29, 2008 at 2:14 pm

    very helpful

  27. 27 Athar Anis June 3, 2008 at 2:47 pm

    very much helpful… when can i get the progress bar bit here???

  28. 28 Athar Anis June 3, 2008 at 3:50 pm

    Ok.. I think i should carry forward the flag now.. as there are many people waiting for the progress bar set up. i know this is not one of the best code but at least does the job.

    I will start by explaining where to find the progress bar from.

    In the Vb6 IDE, click Project -> components. Now look for, Microsoft Windows Common Controls 6.0 (SP6). This should add the progress bar button in the General Tab.
    Can you find it yet? If not then try looking for other Microsoft Windows Common Controls, for example Microsoft Windows Common Controls-2(SP6). Or (SP5)

    Ahaann, I guess you have added it successfully…

    Now, put it on the splash screen described by Sandeep (at the beginning of this blog)

    I have added a LABEL on the form called label2. This label will let the user know about what is actually happening in the background. This gives a better feel.

    Oh yeah, don’t forget to set the interval of the TIMER CONTROL to 1. I know it’s a short delay, but once you get to the code part of this blog, you will realize why I m doing that.

    Next, I declared a variable ‘aa’, the value of which will be embedded in the progress bar’s meter. (Don’t get confused yet, I will explain it soon)

    So in the code, declare a global variable

    Public aa As Integer

    And in the form_load event, I initialized the value of this variable.

    Aa = 0

    Now,

    In the timer1_timer(), add the following code (Depending on the type of work you are doing)

    Private Sub Timer1_Timer()

    ‘ To give the user a feel that the system is working now..
    Screen.MousePointer = 13

    ‘Generate Random Numbers, so that every time you run this page, the progress bar ‘doesn’t process the same. That’s the reason, why timer control’s interval was set to 1.
    aa = aa + (Math.Rnd(1000) Mod 5)

    ‘now set the progress bar’s value
    progressbar1.Value = aa

    ‘Once the progress bar reaches half way, start to establish a connection with the database, ‘and while its been done, notify the user that an attempt is being made
    If progressbar1.Value = 50 Then
    Label2.Caption = “Establishing Database Connection…”

    ‘Here I am trying to open the database connection, CON is the connection string
    ‘declare it too. Public con As New ADODB.Connection
    If con.State = 1 Then con.Close

    ‘Change these settings depending on your server configurations
    con.Open “Driver={SQL Server};Server=fileserver\finos53;Database=asytm;Uid=myuser;Pwd=mypassword;Language=British”

    ElseIf progressbar1.Value = 80 Then
    Screen.MousePointer = 13
    Label2.Caption = “Opening Application…”

    ElseIf progressbar1.Value = 100 Then
    mainform.Show
    Unload Me
    Screen.MousePointer = 0
    End If
    End Sub

    YOU ARE DONE NOW… RUN IT… and hey… like I said, I know its not the best approach, but for the time being, and the User-level I assume you have, it’s a better off.
    For more advance features, tips & tricks and troubleshooting, you can email me anytime on athar_anis@nrlpak.com.

Leave a Reply




Welcome to Sam Ideas

"A man may die, nation may rise and fall, but ideas live on, ideas have endurance to death."

Counting...

  • 79,134 people made me happy