如何在 Visual Basic 5 中从 userDocument Hide 调用 userDocument 终止?
在 Visual Basic 5 文件 (.vbd) 中,如何从 userDocument Hide 调用 userDocument 终止?
Option Explicit
Private Sub Command1_Click()
MsgBox "hello World"
End Sub
Private Sub UserDocument_Hide()
MsgBox "Before Termination"
<I want UserDocument termination here>
MsgBox "After Termination"
End Sub
In a Visual Basic 5 file (.vbd), how do I call userDocument terminate from userDocument Hide?
Option Explicit
Private Sub Command1_Click()
MsgBox "hello World"
End Sub
Private Sub UserDocument_Hide()
MsgBox "Before Termination"
<I want UserDocument termination here>
MsgBox "After Termination"
End Sub
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
虽然您可以调用终止时发生的相同代码,但您实际上无法终止该对象。
当对象的所有引用都被释放时,对象终止就会发生,并且隐式地在其中运行的所有代码都会退出。
对于您想做的事情,您必须获取创建的/正在使用 UserDocument 的任何内容来释放它。
您可以通过在对象中放置一个事件并从调用者侦听并释放该事件的
Hide
事件中调用它来实现此目的。显然,如果调用者不是您的代码,您就无法执行此操作。
While you can call the same code that occurs on termination, you can't actually terminate the object.
Object termination occurs when all references to it are released, and implicitly all code running in it exits.
For what you want to do, you have to get whatever created/is using your UserDocument to release it.
You may be able to do this by putting an event in your object and calling it from the
Hide
event that that caller listens for and releases it.Obviously, if the caller is not your code, you can not do this.