Me.Close不起作用 [英] Me.Close does not work

查看:164
本文介绍了Me.Close不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用VB.net。
我在将应用程序连接到数据库时遇到问题,因此我想添加一个错误处理来关闭表单。



问题是当我在表单中放置 Me.close 时,此表单仍然打开。我使用 Form.Closing 事件处理程序来验证它是否被调用,然后逐步运行我的应用程序,这表明事件处理程序已被调用,但应用程序仍在继续并且错误对用户来说是显而易见的。



有谁知道如何在不关闭应用程序的情况下正确关闭表单?

>关闭 will 才能关闭表单。 / p>

也就是说,表单需要满足两个条件:


  • 关闭必须被调用

  • 任何仍在运行的方法都必须保留



我怀疑另一种方法仍在运行代码,例如导致表单保持打开的循环或其他代码。



<此外,一旦你开始在其他地方访问其成员表格,由于真气属性,表格将自动重新打开VB自动实例化表单。


I'm working with VB.net. I’m having problems while I connect my application to my database today so I wanted to add an error handling to close the form.

The problem is that when I put Me.close in a form, this form still open. I used the Form.Closing event handler to verify that it was called, and then ran my application in step by step which showed that the event handler was called, but the application continues and the errors appears to the user.

Does anyone knows how to close a form properly without closing the application?

解决方案

Close will close a form, but only if it has no more code to run.

That is, there are two conditions that need to be fulfilled for a form to close:

  • Close must be called
  • Any method still running must be left

I suspect that another method is still running code, for instance a loop or other code that causes the form to remain open.

Furthermore, the form will get re-opened automatically once you start accessing its members form elsewhere, due to an infuriating property of VB to auto-instantiate forms.

这篇关于Me.Close不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆