Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 247
Default unload or hide?

should i use unload userform1 or rather userform1.hide?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default unload or hide?

Depends upon what you are trying to do.

If you think you will not use it again in this session, unload it.

If you think that you might use it again, and you don't want the Initialise
code called again, hide it.

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"pswanie" wrote in message
...
should i use unload userform1 or rather userform1.hide?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default unload or hide?

When you Hide a userform, the form is made invisible but it still resides in
memory so you can still access the values of the various controls that the
user changed. You would use Hide if your code needs to access the
userform's values after it is hidden. When you Unload a userform, the form
is made invisible and it is dumped out of memory. After an Unload, the
values on the form changed by the user are inaccessible and any attempt to
reference a control returm the default value (or possibly a error 91) of the
control (typically and empty string) rather than the value selected by the
user.

If you no longer need to get the values from a form once the user clicks
"Close", you should Unload the form. If, however, your code needs the
values from the form after it has been closed, use Hide and then once your
code is done with the form, Unload it. For example,

Sub AAA()
UserForm1.Show
''''''''''''''''''''''''''''''''''''''''''
' If the form is dismissed with Hide,
' we can still get the values from the
' form:
''''''''''''''''''''''''''''''''''''''''''
Debug.Print UserForm1.TextBox1.Text
''''''''''''''''''''''''''''''''''''''''''
' Once we Unload the form, the values from
' the controls are lost.
''''''''''''''''''''''''''''''''''''''''''
Unload UserForm1
Debug.Print UserForm1.TextBox1.Text
End Sub

Cordially,
Chip Pearson
Microsoft MVP, Excel Product Group, 1998 - 2008
Pearson Software Consulting, LLC
www.cpearson.com
(email on th web site)

"pswanie" wrote in message
...
should i use unload userform1 or rather userform1.hide?


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unload vs Hide CV323 Excel Programming 6 May 11th 07 02:14 PM
Unload/Hide Userform when switching to a new Wbk avi Excel Programming 1 March 14th 07 08:25 PM
Userform Question (Load/Unload/Show/Hide) RPIJG[_76_] Excel Programming 8 November 2nd 05 08:29 PM
Unload the form on esc key Papou Excel Programming 0 August 10th 04 05:15 PM
Unload Me Chip Pearson Excel Programming 0 September 5th 03 12:56 AM


All times are GMT +1. The time now is 07:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"