Forms

Showing a form

To show a form you can use the Show method. This will automatically load the form into the memory (if not already loaded), and then display the form. The following statement displays Form1:

Form1.Show

You might want to show a form, and stop all code until it has been closed. You would use this for an options dialog for example. The following code displays Options1, and then displays a message box after it has been closed

Options1.Show vbModal
Msgbox "Options1 Closed"

To see how this differs from normal, remove the text vbModal.

Sometimes, you will want to load the form into the memory, but not show it straight away. This would be the case if you wanted to load your main form while displaying a splash form. To do this you can use the Load method. Load takes the following form:

Load Form

The following code shows Splash1 (the splash form), then loads Main1 (the main form), then removes Splash1 from the memory (see Hiding Forms) and displays Main1.

' Show the splash form
Splash1.Show
' Load the main form
Load Main1
' Unload the Splash form
Unload Splash1
' Show the main form
Main1.Show

You might also like...

Comments

About the author

James Crowley

James Crowley United Kingdom

James first started this website when learning Visual Basic back in 1999 whilst studying his GCSEs. The site grew steadily over the years while being run as a hobby - to a regular monthly audien...

Interested in writing for us? Find out more.

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“XML is like violence - if it's not working for you, you're not using enough of it.”