Senin, 02 Februari 2009

Creation of Simple Splash Screen - VB2005

by : Dilerious
THIS IS A TUTORIAL FOR VISUAL STUDIO 2005!


This will add a splash screen template. This is good as it has no toolbar at the top so it will look more professional.

Delete everything on the splash screen template and set the background colour to white. Add some text/images to the splash screen to display your application name/copyright/version etc.

Go to the Toolbox and add a timer to your project. Set the timer to “Enabled = False” in the Properties window. Go to your code and in the FormLoad sub put this code:


CODE

Timer1.Enabled = True




Now go back to the design view and add a Progress Bar to the Splash screen.
Add a label under your progress bar and remember the name of it.
Then paste this into your code replacing “Label2” with the name of your label underneath your progress bar.


CODE

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

If ProgressBar1.Value <> ProgressBar1.Maximum Then
ProgressBar1.Value = (ProgressBar1.Value + 1)
Label2.Text = "Loading " & ProgressBar1.Value & "% Complete"
End If

End Sub




This code will make the progress bar work. The timer will add a value of 1 at every interval it is set to. You can leave it like this, but it doesn’t look much like a normal progress bar. To make it real, we’ll change the timer interval, thus changing the speed of the progress bar, at regular intervals. This will make it look a bit more random and like a real progress bar.

To add these random speed changes we need to edit the code I posted above. If you want to leave your progress bar at a constant speed then please ignore the next code snippets.

Add sections of code like this one after the “End If” statement but before the “End Sub” statement. You want these code snippets to be in the “Timer1.Tick” sub:


CODE

If ProgressBar1.Value = 1 Then
Timer1.Interval = 800
End If




The Value of the progress bar is the percentage it is at. The timer interval is the speed the progress bar would fill up at. To make it fill faster when it reached, lets say, 12%. Add this code:


CODE

If ProgressBar1.Value = 12 Then
Timer1.Interval = 200
End If




Lowering the timer interval will make it go faster. Keep adding more of these sections one after another to make your progress bar random. These are the first 5 of my progress bar timer:


CODE

If ProgressBar1.Value = 1 Then
Timer1.Interval = 800
End If

If ProgressBar1.Value = 2 Then
Timer1.Interval = 75
End If

If ProgressBar1.Value = 12 Then
Timer1.Interval = 600
End If

If ProgressBar1.Value = 14 Then
Timer1.Interval = 4000
End If

If ProgressBar1.Value = 15 Then
Timer1.Interval = 1
End If




At the end of all that, When the loading is completed, You can either add a button which will open the main form, or it can do it automatically. If you wish to add a button, please follow the instructions below. If you wish to make your program do it automatically please jump to ***

If you want to add a button, Place a button on your splash screen and set it to be not visible. Call it “cmdBegin”. Add this code to the Timer1.Tick Sub (Underneath all the interval changes):


CODE

If ProgressBar1.Value = 100 Then
Label2.Text = "Loading Complete"
cmdBegin.Visible = True
Timer1.Enabled = False
End If




This will change the label underneath the progress bar, will make the begin button visible and will turn the timer off.

Add a new form as the main window and call it FrmMain.

Double click the ‘begin’ button in design view and add this code to the sub it creates for you:


CODE

Private Sub cmdBegin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdBegin.Click
FrmMain.Visible = True
Me.Visible = False
End Sub




This will show the main window and hide the splash screen.

***
Create a new form and call it FrmMain. Add this code to the end of the Timer1.Tick sub.


CODE

If ProgressBar1.Value = 100 Then
FrmMain.Visible = True
Me.Visible = False
End If




This will hide the splash screen and display the main window as soon as the progress bar reaches 100%




source :http://www.dreamincode.net

-------------------------------------------------------

Trik Gambar Bergerak

Trik Gambar-dimouse

Trik hapus pwd mysql

Trik insertin to db

Trik jadi root dilinux

Trik jam-distatus-bar

Trik Koneksi-ke database

Trik Koneksi-msql-php

Trik lihat-database-mysql

Trik membahas-fungsi-else

Trik member-area