Which is First Form in Project?

  • Thread starter Thread starter Alan M Dunsmuir
  • Start date Start date
A

Alan M Dunsmuir

Something very basic I either never thought about, or (more likely) once
knew and by now have totally forgotten.

I have developed a Windows application in VB.NET, all based on a single
Form. I would now like to add a Splash Screen to the project, which
should be seen by the user whenever the project is launched, before the
main Form is displayed.

How do I do this?
 
Hi Alan,

Create your splash screen form. In Visual Studio, right-click your
project and go to Properties. Under the "General" item of the "Common
Properties" category there will be a drop-down box called "Startup
Object". It'll be on the second line down.

You have two choices for the entrypoint: either a Sub Main() somewhere
in your code or a form (the compiler generates a Sub Main() for you and
simply Application.Run()'s your new form in it).

Change the Startup Object to point to your splashscreen form and it will
be the first form displayed. Then you start the main form via the splash
screen.

Hope that helps!

Regards,
-Adam.
 
Right click your application in the solution explorer, then properties,
there you can select startup object.

Greetz Peter
 
Alan,

A form is not showed before the load event of that form is finished (when
you not force that with me.show in the sub new or that loadevent).

Therefore you can set in the load event of your main form
dim splash as new form2
splash.showdialog
splash.dispose

On that form2 you drag a timer and set it to enable = true and set the
interval too the miliseconds you wants

Than you create in that form a timer elepsed event with only in that
me.close

Your splash form is ready.

I hope this helps?

Cor
 
Adam Goossens said:
Hi Alan,

Create your splash screen form. In Visual Studio, right-click your project and
go to Properties. Under the "General" item of the "Common Properties"
category there will be a drop-down box called "Startup Object". It'll be on the
second line down.
Thanks for that pointer. I really don't know how I managed to miss it in
my check through of possibilities.

Now another related point.

Once the project is executing, what's the simplest way of switching from
one form to another?

In VB6 I used to go

Forms!Form2.Activate
Forms!Form1.Close

With VB.NET the closest equivalent I can find (since it won't allow me
to point directly at Form2 from inside Form1) is:

Dim myForm2 as New Form2
Me.Hide

Here, if I try closing Form1 instead of simply hiding it, the whole
project shuts down.

Is this the best and most direct way of switching from one form to
another?

Does this mean that in a complex application consisting of many
different forms, I have to leave them all open behind me as I navigate
from one to the next?

Doesn't this have significant memory implications?
 
You can use

dim objForm as new Form1
objForm.show

for example if you have a menu and when you click on a menuitem and you want
to show a form you can use this code

hth greetz Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top