i want to make my own splash screen. which appear on start of my program and after it finish my login screen come. i write one program based of 3 timers which is working fine but it not loading my form2 the code is

Public Class Form1

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    Timer2.Enabled = True
    Timer1.Enabled = False

End Sub

Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
    Me.Opacity = Me.Opacity - 0.1

End Sub

Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
    If Me.Opacity = 0 Then
        Me.Hide()
        form2.show()

    End If
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

End Class

Recommended Answers

All 9 Replies

I think your problem here is that Timer3 hasn't been called to start ticking. What I think you need to do is on the first form load place e.g. (Timer1.Stat()) to start timer1 then maybe on timer1 you can start the second timer and ensure that you stop timer1 and on timer2 you start the third timer and also ensure you stop timer2 and finally on timer3 you can leave your codes as is and also do stop timer3 after firing the events. You need to make is sort of a chain.

can you please type code for me.

i did the same way but 2nd form i can not able to close it or when i enter user and password i am able to access my software but login screen remain same

This codes always run when the Application starts. You have to put the codes in MyApplication Class. You get this Class in ApplicationEvents.vb Class file. There is no need to use a Timer control.
Goto Project Properties window -> Application Tab ->Select Splash in Splash Screen ComboBox.
Now open ApplicationEvents.vb Class file by double clicking in Solution Explorer. If you do not find it in Solution Explorer GoTo Properties Window ->Application Tab -> Click on View Application Events Button. Now you can get it.
Now you can write your codes, which would be run at startup.
Here I am posting some codes, which I used for a Cable Network Billing System.

Namespace My

    ' The following events are available for MyApplication:
    ' 
    ' Startup: Raised when the application starts, before the startup form is created.
    ' Shutdown: Raised after all application forms are closed.  This event is not raised if the application terminates abnormally.
    ' UnhandledException: Raised if the application encounters an unhandled exception.
    ' StartupNextInstance: Raised when launching a single-instance application and the application is already active. 
    ' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected.
    Partial Friend Class MyApplication

        Protected Overrides Function OnInitialize(ByVal commandLineArgs As System.Collections.ObjectModel.ReadOnlyCollection(Of String)) As Boolean
            ' ----- Display the splash form for at least 5 seconds.
            My.Application.MinimumSplashScreenDisplayTime = 5000
            Return MyBase.OnInitialize(commandLineArgs)
        End Function

        Private Sub MyApplication_Shutdown(sender As Object, e As System.EventArgs) Handles Me.Shutdown
            'Close the open connection at the time of shutdown
            ModuleMain.CloseConnection()
            'My.Application.ShutdownStyle = ApplicationServices.ShutdownMode.AfterMainFormCloses

        End Sub
        Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup
            'Application Starts Here

TryToOpenFile:
            'Retriving the database connection string from an xml file.
            Dim conStr As New ClassConnectionString
            If Not System.IO.File.Exists(CblDataPath & "\CableSolution.xml") Then
                cblConnString = FormConnectionString.ConstructConnectionString()
                If Not String.IsNullOrEmpty(cblConnString) Then
                    conStr.Conn_String = cblConnString
                    conStr.SaveSerializeData(CblDataPath)
                End If
            End If
            cblConnString = conStr.GetSerializeData(CblDataPath)
            If Not String.IsNullOrEmpty(cblConnString) Then
                'Open Database connection
                ModuleMain.OpenConnection(cblConnString)

                'Check here for UserID and Password(If Any)
                'If there is no User Show the MainForm Normally.
                If ModuleLogIn.LogInData Then
                    Me.ShowLogInCheck(e)
                Else
                    FormMain.Show()
                End If

            Else
                Select Case MessageBox.Show("Database connection is corrupted." & vbCrLf & "Do you sure to rebuild the connection?", My.Application.Info.AssemblyName, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)
                    Case DialogResult.Yes
                        System.IO.File.Delete(CblDataPath & "\CableSolution.xml")
                        GoTo TryToOpenFile
                    Case DialogResult.No
                        Me.HideSplashScreen()
                        e.Cancel = True
                End Select
            End If
        End Sub

        Public Sub ShowLogInCheck(ByVal xe As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs)
            'Show the form for UserID and PassWord.
            FormLogIn.ShowDialog()
            If FormLogIn.DialogResult = DialogResult.OK Then
                If (FormLogIn.TextBoxUserName.Text.Trim <> "") And (FormLogIn.TextBoxPassWord.Text.Trim <> "") Then
                    If ModuleLogIn.CheckSecurity(FormLogIn.TextBoxUserName.Text, FormLogIn.TextBoxPassWord.Text) Then
                        CblUserName = FormLogIn.TextBoxUserName.Text.Trim
                        cblUserType = ModuleLogIn.CheckUserType(FormLogIn.TextBoxUserName.Text, FormLogIn.TextBoxPassWord.Text)

                        'If UserID and Password is Valid, show the MainForm
                        FormMain.Show()
                    Else
                        'give an another chance to user 
                        'after inputting invalid UserID and PassWord.
                        FormLogIn.LabelMessage.Text = "Invalid user name or password."
                        Me.ShowLogInCheck(xe)
                    End If
                Else
                    'give an another chance to user 
                    'after inputting invalid UserID and PassWord.
                    FormLogIn.LabelMessage.Text = "Invalid user name or password."
                    Me.ShowLogInCheck(xe)
                End If
            Else

                'Exit from Application 
                ModuleMain.CloseConnection()
                xe.Cancel = True
            End If
        End Sub

    Private Sub MyApplication_StartupNextInstance(ByVal sender As Object, _
          ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupNextInstanceEventArgs) _
          Handles Me.StartupNextInstance
        ' ----- Force the main form to the front.
        My.Application.FormMain.Activate()
    End Sub

    Private Sub MyApplication_UnhandledException(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.UnhandledExceptionEventArgs) Handles Me.UnhandledException
        ' ----- Record the error, and keep running.
        e.ExitApplication = False
        GeneralError("Unhandled Exception", e.Exception)
    End Sub

    End Class


End Namespace

Here I am trying to show you how you can do it at Application starts up time. But codes , how do you write and represent the front end to your user, are your own choice .
Hope it could help you.

Thank you for your reply

but i need any small code or any simple way for splash screen.

You don't need any coding to display a splash screen. In solution explorer click on My Project and in the Application windown, down the bottom you can select any of your form as splash screen. This will pop up before your first form loads.

thanks Minimalist

it works but can i increase the time of splash like 5 to 6 secnd? becz i have animation splash of 5 6 secnd but this option allow splash to close aftr 1 2 secnds. can i increase time ?

To increase the time you will have to write your code in MyApplication Class.
Put the following codes in MyApplication Class

Protected Overrides Function OnInitialize(ByVal commandLineArgs As System.Collections.ObjectModel.ReadOnlyCollection(Of String)) As Boolean
            ' ----- Display the splash form for at least 5 seconds.
            My.Application.MinimumSplashScreenDisplayTime = 5000
            Return MyBase.OnInitialize(commandLineArgs)
        End Function

Hope it should help you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.