Post: [Visual Basic] Noob Needs Help!
02-15-2011, 08:38 PM #1
(adsbygoogle = window.adsbygoogle || []).push({}); Hey everyone =D

I just downloaded and opened Visual Basic 2010 Express for the first time and I'm in need of some help to get started.

I'm looking to make a program that will start with a splash screen and then automatically move onto the main application, kind of like the Adobe products where there's a little splash screen while it loads and then it goes to the 'main program'. (See example below)

You must login or register to view this content.


I've managed to make a form which will be my main program and also added a default Splash Screen by going to 'Add New Item..' I have tried adding a button on the actual Splash that takes the user on to the form when clicker, BUT what I want is for it to move on to it automatically.

So it's like Splash (5-10 secs) > Form1.

It's probably very simple but like I said I only just opened this for the first time now xD

Anyone know what code and where I need to put it for this? :O
02-15-2011, 08:54 PM #2
[VG]Mars
Save Point
Within the form which you are using as your splash screen you can the following to cause a pause before it vanishes and the main form appears.


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Threading.Thread.Sleep(5000)
Me.Hide()
form2.show()
End Sub


Form 1 in this case being your splash screen and Form 2 being the Main form for the program.
The (5000) is 5000 milliseconds for the program to wait, 1000ms is 1 second.
Hope that helps.
Last edited by [VG]Mars ; 02-15-2011 at 08:56 PM.
02-15-2011, 09:26 PM #3
[quote='[VG]Mars;2575724']Within the form which you are using as your splash screen you can the following to cause a pause before it vanishes and the main form appears.


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Threading.Thread.Sleep(5000)
Me.Hide()
form2.show()
End Sub


Form 1 in this case being your splash screen and Form 2 being the Main form for the program.
The (5000) is 5000 milliseconds for the program to wait, 1000ms is 1 second.
Hope that helps.[/quote]Thanks for the quick reply.

So, I have made 2 new forms and called them Form1 and Form2. I added your code in Form1 so now it looks like this:

    Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Threading.Thread.Sleep(2000)
Me.Hide()
Form2.Show()
End Sub
End Class


What's wrong? Because when i try to run it it just waits a couple seconds then both forms open at the same time.
02-15-2011, 10:22 PM #4
Originally posted by ccarlsen View Post
original post


I came up with a better solution, add 2 windows forms(Just like you did earlier), then design your splash screen(Form2 is your splash screenWinky Winky ) Then add a timer, click the timer, and set the interval to however long you want the splash screen displayed, 1000 for an interval is one second so say if you want the splash screen displayed for 5 seconds, make the interval 5000Winky Winky Now you want to double click on Form1, don't worry about any coding at all for your Form2. And now you want to add in:
    Timer1.Enabled = True

So now it should look like this:
You must login or register to view this content.

Now double click the timer, and add the following code for it:
    
Form2.Show()
Timer1.Enabled = False
Me.Hide()

It should now look like this:
You must login or register to view this content.

Now, debug it, and it should workSmile

All in all, the designer should look like this when done coding:
You must login or register to view this content.

The following 2 users say thank you to skitterz for this useful post:

[VG]Mars, ccarlsen
02-15-2011, 11:39 PM #5
Originally posted by skitterz View Post
I came up with a better solution, add 2 windows forms(Just like you did earlier), then design your splash screen(Form2 is your splash screenWinky Winky ) Then add a timer, click the timer, and set the interval to however long you want the splash screen displayed, 1000 for an interval is one second so say if you want the splash screen displayed for 5 seconds, make the interval 5000Winky Winky Now you want to double click on Form1, don't worry about any coding at all for your Form2. And now you want to add in:
    Timer1.Enabled = True

So now it should look like this:
You must login or register to view this content.

Now double click the timer, and add the following code for it:
    
Form2.Show()
Timer1.Enabled = False
Me.Hide()

It should now look like this:
You must login or register to view this content.

Now, debug it, and it should workSmile

All in all, the designer should look like this when done coding:
You must login or register to view this content.
It's getting late but this looks very promising.

Thank you kind sir for teh help :carling:
02-15-2011, 11:42 PM #6
[VG]Mars
Save Point
Originally posted by ccarlsen View Post

What's wrong? Because when i try to run it it just waits a couple seconds then both forms open at the same time.


My bad, I rushed into posting without thinking. Threading.Thread.Sleep is good for creating a pause if someone is spamming a button, but in this case doesn't work. But hey the answer that should have been right under my nose has been posted, so hopefully everything's going well for you now.

The following 2 users say thank you to [VG]Mars for this useful post:

ccarlsen, skitterz
02-15-2011, 11:52 PM #7
Originally posted by ccarlsen View Post
It's getting late but this looks very promising.

Thank you kind sir for teh help :carling:


worked perfect for me:black:
02-16-2011, 02:38 PM #8
Originally posted by skitterz View Post
worked perfect for me:black:
It's. Not. Working :gluk:
I followed your instructions exactly but I get a couple errors so I can't debug it. Screenshots below:

You must login or register to view this content.
(Form1)

You must login or register to view this content.
(Form2)

Help? :FU:
02-16-2011, 03:13 PM #9
Member 2484
Porn? WTF IS PORN
Originally posted by ccarlsen View Post
It's. Not. Working :gluk:
I followed your instructions exactly but I get a couple errors so I can't debug it. Screenshots below:

You must login or register to view this content.
(Form1)

You must login or register to view this content.
(Form2)

Help? :FU:


Give me 5 mins, ill try it and see what your problem is :y:

You got teamviewer? i think i know your problem
Last edited by Member 2484 ; 02-16-2011 at 03:20 PM.
02-16-2011, 03:21 PM #10
Spirant
Bounty hunter
Originally posted by ccarlsen View Post
It's. Not. Working :gluk:
I followed your instructions exactly but I get a couple errors so I can't debug it. Screenshots below:

You must login or register to view this content.
(Form1)

You must login or register to view this content.
(Form2)

Help? :FU:


You can't disable one timer from a different form, lets say you have Timer1 in form1, you can't disable it from form2.

It's pretty easy to fix.

Lets say Form1 is your loading screen, add a timer to Form1. Now add this code on timer1_tick (Double click the timer):
    
Me.Hide()
Form2.Show()
Timer1.Stop()


Make timer1 enabled by default, less code, much easier.
Images i made, so maybe it will be easier to follow my instructions Smile
You must login or register to view this content.
You must login or register to view this content.

The following user thanked Spirant for this useful post:

ccarlsen

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo