ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Load and Unload Form commands (https://www.excelbanter.com/excel-programming/305024-load-unload-form-commands.html)

R Avery

Load and Unload Form commands
 
When are these commands needed? I never seem to need to load or unload
a form in my code; all forms seem to be loaded all the time, and never
unload even after i use the unload frmMYFORM function. What do they do?

Jim Rech

Load and Unload Form commands
 
I personally have never used Load since a Show will do a Load if needed. I
suppose if you had a long initialization routine you might do a separate
Load so the eventual Show is not delayed.

Unload clears the form from memory, so besides freeing the memory, it would
cause the form to re-initialize the next time it is shown. If you just do a
Hide the form will retain its current control values at the next Show.

--
Jim Rech
Excel MVP
"R Avery" wrote in message
...
| When are these commands needed? I never seem to need to load or unload
| a form in my code; all forms seem to be loaded all the time, and never
| unload even after i use the unload frmMYFORM function. What do they do?



Wassim

Load and Unload Form commands
 
R Avery wrote in message ...
When are these commands needed? I never seem to need to load or unload
a form in my code; all forms seem to be loaded all the time, and never
unload even after i use the unload frmMYFORM function. What do they do?


Hello

You asked about the Load and Unload commands as they apply to
Userforms.

I will give you some of my interpretation about these two commands:

Loading a form, places it in memory where you can manipulate it before
the user interact with it. Once the Show command is issued the form
will be displayed.

You will want to do this if you need to initialize the form, say you
want to hide objects on it, and have the user see a form that will
change based on some event, mainly user input. This loading of the
form can speed up the displaying of the form, if you have a
complicated form.

Well now the unload will simply remove the form from memory. That
means you can not refer to it, or manipulate it or its objects.

When an object is unloaded, it's removed from memory and all memory
associated with the object is reclaimed. That means you will lose all
user changes of the form.

It will be OK to hide the form, because hide still retains the memory
allocated, and thus you can still manipulate and grab information from
the form.

I always unload userforms when I am done, because of memory and
security issues.

I hope I answered your questions.

Wassim

Tom Ogilvy

Load and Unload Form commands
 
This loading of the
form can speed up the displaying of the form, if you have a
complicated form.


So you say

Load Userform1
Userform1.Show

is faster than

Userform1.Show

Interesting.

Well now the unload will simply remove the form from memory. That
means you can not refer to it, or manipulate it or its objects.


Unload Userform1
Userform1.Textbox1.Value = "ABC"

will not reference the old instance of Userform1, but it will load a new
instance of userform1 and manipulate textbox1. (an explicit load is not
required).

--
Regards,
Tom Ogilvy


"Wassim" wrote in message
m...
R Avery wrote in message

...
When are these commands needed? I never seem to need to load or unload
a form in my code; all forms seem to be loaded all the time, and never
unload even after i use the unload frmMYFORM function. What do they do?


Hello

You asked about the Load and Unload commands as they apply to
Userforms.

I will give you some of my interpretation about these two commands:

Loading a form, places it in memory where you can manipulate it before
the user interact with it. Once the Show command is issued the form
will be displayed.

You will want to do this if you need to initialize the form, say you
want to hide objects on it, and have the user see a form that will
change based on some event, mainly user input. This loading of the
form can speed up the displaying of the form, if you have a
complicated form.

Well now the unload will simply remove the form from memory. That
means you can not refer to it, or manipulate it or its objects.

When an object is unloaded, it's removed from memory and all memory
associated with the object is reclaimed. That means you will lose all
user changes of the form.

It will be OK to hide the form, because hide still retains the memory
allocated, and thus you can still manipulate and grab information from
the form.

I always unload userforms when I am done, because of memory and
security issues.

I hope I answered your questions.

Wassim




R Avery

Load and Unload Form commands
 
Thanks!


All times are GMT +1. The time now is 09:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com