VB中End方法和Unload方法比较

End方法:
      Terminates execution immediately. Never required by itself but may be placed anywhere in a procedure to end code execution, close files opened with the Open statement and to clear .
    

When executed, the End statement resets all variables and all static local variables in all . To preserve the value of these variables, use the Stop statement instead. You can then resume execution while preserving the value of those variables.

Note    The End statement stops code execution abruptly, without invoking the Unload, QueryUnload, or Terminate event, or any other Visual Basic code. Code you have placed in the Unload, QueryUnload, and Terminate events of and is not executed. Objects created from class modules are destroyed, files opened using the Open statement are closed, and memory used by your program is freed. Object references held by other programs are invalidated.

The End statement provides a way to force your program to halt. For normal termination of a Visual Basic program, you should unload all forms. Your program closes as soon as there are no other programs holding references to objects created from your public class modules and no code executing.

Unload方法:
     Unloading a form. or control may be necessary or expedient in some cases where the memory used is needed for something else, or when you need to reset properties to their original values.

Before a form. is unloaded, the Query_Unload event procedure occurs, followed by the Form_Unload event procedure. Setting the cancel argument to True in either of these events prevents the form. from being unloaded. For MDIForm objects, the MDIForm object's Query_Unload event procedure occurs, followed by the Query_Unload event procedure and Form_Unload event procedure for each form, and finally the MDIForm object's Form_Unload event procedure.

When a form. is unloaded, all controls placed on the form. at are no longer accessible. Controls placed on the form. at remain intact; however, any run-time changes to those controls and their properties are lost when the form. is reloaded. All changes to form. properties are also lost. Accessing any controls on the form. causes it to be reloaded.

Note    When a form. is unloaded, only the displayed component is unloaded. The code associated with the form. module remains in memory.

Only control array elements added to a form. at run time can be unloaded with the Unload statement. The properties of unloaded controls are reinitialized when the controls are reloaded.

在vb中要结束某个应用程序并退出时,如果只使用Unload Me的话,程序的显示组件被Unload掉,但是相关的程序代码还会驻留在内存中,使用end方法的话会清理变量释放内存,但是我想可以Unload Me 之后再执行End

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/11411056/viewspace-734289/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/11411056/viewspace-734289/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值