ITPub博客

首页 > Linux操作系统 > Linux操作系统 > VB中End方法和Unload方法比较

VB中End方法和Unload方法比较

原创 Linux操作系统 作者:ljm0211 时间:2012-07-02 10:53:46 0 删除 编辑

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/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2009-05-14

  • 博文量
    272
  • 访问量
    436875