What's the difference between .show and Load?

What's the difference between .show and Load?

<formname>.show and load <formname>

Thank you.
Who is Participating?
JediConnect With a Mentor Commented:
When the show method is called, the form is loaded if needed (if the form is not loaded) and then displayed(showed).
When load is used the form is just loaded(the form load is executed) not displayed(showed).

Typicallly you can load all forms in an application during a spash screen to  and then And then call show and hide to display and undisplay the forms to make the application appair faster.

Ooups, I wnated to answer it - so I give it as a comment!

A Form has to be loaded, before it can be shown.

You do not always recognize this, because VB automatic loads a Form, whren you call the Show-Method.

You can Hide a form, and the form is still loaded: You can see this, by i.e. changing the caption of a label: Perhaps you call

(Form1.Load) (may be ommitted, is automatically called)
Label1.Caption = "changed Label"

where Label1 lies on Form1.

If you call now Form1.Show, you'll see the changed Caption.
But if you Unload Form1 and then try to talk to any of the objects, variables etc. owned by this form, you'll get an error.

You can hide and show a form, if you have to set some values on the form, although the user should actually not see the form.

If you Unload a Form, you free the memory, that is better regardfing the point of performance.
If you Unload a Form, it is definitely finished. You normally do this, if you do not need it any more or if you'll need it again, but as a new initialized version.

I.E. a MessageBox is a form that is always loaded, shown and unloaded. It is only used one and goes away after beeing used.

There are other Events as Terminate, QueryUnload, Activate, which should to be considered. That best way is to write a sample application, with two forms, where you use Labels on the first form, which gets their captions from the different Events on the second Form i.e. Form_Load, Form_Unload, Form_Show - like that you'll see there occurence.

Good Luck and ask again, if needed

iamjhkangAuthor Commented:
Thank you Jedy and db_tiger.

I got it.

By just LOADing a form W/O SHOW I can see the form.
Try using an object variable

Dim objX As YourForm

Set objX = New YourForm
iamjhkangAuthor Commented:
Thank you.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.