Differences between "end", "unload me", and "Exit Sub" in VB

Source: Internet
Author: User



I have thought about this before. These familiar things are not very thorough analysis on them, and "end" and "unload me" are hitting the program.

It is often said, "Exit Sub" is more familiar, the following, analysis:



End and unload me

End is to force the end of the entire program, while unload me is to uninstall the current form. When the last form in the program is uninstalled, the entire program will automatically

End. If the current form is not the last form in the program, the program will not end.


Simply put, the end is all ended, and the unload me is for the current window.


Relatively speaking, the end is forced to close, and the form_unload and form_terminate events will not occur. Before the unload me is closed, the above 2 events will occur.

Events. You can add Exit Processing code to the event above and add some instructions for using the adodc control to add, modify, display, and so on...



End sub and exit sub


For each process, end subMust have and must have only oneAnd exit sub can have or not, either, or many,


End sub indicates the end of the process code. Exit sub indicates the exit process. If it is executed, the code that belongs to the process is not

Will be executed, usually used for intermediate judgment, such as when certain conditions are met, directly exit the process without executing the following code,



In addition, there is an interesting saying:


Exit sub = deserters or midway skydiving

End sub = end the battle





To put it simply:


Unload meDetach yourself, that is, detach the current form


Exit subEnd Process/jump out of this Process

EndEnd all





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.