joao
joao

Reputation: 133

Load Another Form With Splashscreen VB.NET

So I'm developing a game and it's a little heavy on some systems, so here's what I would like to do when the game opens (pseudo code):

Show Splashscreen
Load GameForm
When GameForm Is Completely Loaded
Splashscreen Close
Show GameForm

How is this done in actual VB code?

Upvotes: 3

Views: 15550

Answers (2)

CG.
CG.

Reputation: 186

VB.NET 2010 (others?) has a built-in Splash Screen assignment mechanism.

Add a splash screen to your Winform project. Project Menu -> Add New Item -> select "Splash Screen"

In the splash screen code window it gives you a hint how to do it.

'TODO: This form can easily be set as the splash screen for the application by going to the "Application" tab
'  of the Project Designer ("Properties" under the "Project" menu).

Basically, in the Project Properties, under the Application Tab, at the bottom, there is an option to select a Splash Screen.

The code that is added by this change to your project in the Application.Designer.vb file is:

    <Global.System.Diagnostics.DebuggerStepThroughAttribute()>  _
    Protected Overrides Sub OnCreateSplashScreen()
        Me.SplashScreen = Global.WindowsApplication1.SplashScreen1
    End Sub

By default, this method of assigning a splash screen shows it for 2000 milliseconds.

You can read the documentation for other usage @MSDN

Upvotes: 4

Jeremy Thompson
Jeremy Thompson

Reputation: 65682

Open Visual Studio > new VB.Net Winform Project

Right click Solution > Add New Item > SplashScreen

Double click Form1 and in the Form1_Load event:

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

Me.Visible = False

Dim s = New SplashScreen1()
s.Show()
'Do processing here or thread.sleep to illustrate the concept
System.Threading.Thread.Sleep(5000)
s.Close()

Me.Visible = True

End Sub

Upvotes: 6

Related Questions