-2

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
Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
Abhi
  • 226
  • 2
  • 13
  • @SLaks No, it's actually about [VB5 user documents](http://stackoverflow.com/questions/1479614/are-there-any-good-resources-for-dealing-with-user-document-dob-files). – GSerg Dec 23 '11 at 19:52

1 Answers1

3

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.

Deanna
  • 23,876
  • 7
  • 71
  • 156
  • Thanks.... We were trying to overcome one problem. i.e. when the VBD documents are opened in IE and were navigated the previous documents were not getting unloaded from memory which resulted in memory leaks/shootup. We found that if we use the IFrame containers and load those documents in the frames we don't face the same problem. – Abhi Feb 15 '12 at 02:05