![]() |
Form temporary variables
I wish to declare temporary variables that will be declared when a form is
shown, will be visible to all form subroutines and "deleted" (so that memory is released) after the form is hidden again. Is this possible? If not what is the best way to declare variables visible to all form subroutines? Public....???? |
Form temporary variables
If you really meant "hide", as you said, rather than "close", then you can't
do what you want. To make a variable, global to your form, which will cease to exist when the UserForm is **closed**, simply Dim it in the (General)(Declarations) section of the UserForm's code window (that is, at the top of the code window and outside of any other procedure). -- Rick (MVP - Excel) "DoctorG" wrote in message ... I wish to declare temporary variables that will be declared when a form is shown, will be visible to all form subroutines and "deleted" (so that memory is released) after the form is hidden again. Is this possible? If not what is the best way to declare variables visible to all form subroutines? Public....???? |
Form temporary variables
When a form is loaded using the Show method, the variables contained within
the underlying code for the form and for the controls are all temporary. Once the form is unloaded, all values of those variables are dumped from memory. As Rick suggested, during design mode, you can use the View Code to access the UserForm code module, where you can declare any variables at the top of the module that you want to apply to any of the procedures within the form and the controls it contains. Again, any variable declared within a UserForm, its procedures and its controls' procedures are temporary. They only last for the active life of the UserForm, although they will re-initialize each time the form is loaded. "DoctorG" wrote: I wish to declare temporary variables that will be declared when a form is shown, will be visible to all form subroutines and "deleted" (so that memory is released) after the form is hidden again. Is this possible? If not what is the best way to declare variables visible to all form subroutines? Public....???? |
All times are GMT +1. The time now is 02:33 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com