Close userform using myForm.Hide or Unload Me

允我心安 提交于 2019-12-02 16:57:26

问题


Before I start let me give you the background. I am working on a VBA project with Excel and the computer I am using has limited resources (and I have been asked to do as light as possible for fast execution time). In my project I open multiple userform at different times, to apply filters on my sheet for example.

As I just said resources are limited and I want to know if frmFilters.Hide is enough to close the userform or if there is a better way to do so ?

I've read about Unload Me but I'm not sure how it's working because I'll apply filters from my form and I need to keep them once the form is closed until the user totally close the Excel file.

Is there a situation where Unload Me is better than frmFilters.Hide ?

Regards, Teasel


回答1:


I found an interesting answer to my question I thought it would be useful to post it here.

Unload me

Unload me

Removes the form from the memory and stop the application if you do so on the main form of your project. Every modification that you did in your form will be lost.

Hide

myForm.Hide

Only hide the form. If you do so on the main form of your application, this will not end the program (the debug mode would still be running for example). Every modification that you do in your form will be kept for the next time you show your form.

Which one to use?

Depends of the situation I believe. In my project, my form was made to be open/close multiple times so I chose to only hide it to avoid having to allow memory for my form every time.



来源:https://stackoverflow.com/questions/45838982/close-userform-using-myform-hide-or-unload-me

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!