• 0

[vb6] On Form Unload, Close App


Question

I have an app, which has 3 forms, but only 1 shows at a time, so I have to have the others hidden. When you click the x close button, the app dissapears, but its still running in the task manager. What i need is code for when you click the x close button, it unloads all the forms and closes down properly.

Thankyou in advance.

Link to comment
https://www.neowin.net/forum/topic/170387-vb6-on-form-unload-close-app/
Share on other sites

16 answers to this question

Recommended Posts

  • 0

not sure where to put this

  Quote
Private Sub Form_Load()

Dim frm As Form

For Each frm In Forms

      Unload frm

      Set frm = Nothing

Next frm

End

End Sub

its working, but the program just closes when the form opens, i know i'm not supposed to put it in form load, but where?

  • 0

Private Sub Form_Unload()
     Dim frm As Form
          For Each frm In Forms
           Unload frm
           Set frm = Nothing
          Next frm
     End
End Sub

:p

stick that in the main form, as when that one gets closed it will close all other forms and end the program.

  • 0

thanks all, got it now :)

Private Sub Form_Unload(cancel As Integer)
    Dim frm As Form
         For Each frm In Forms
          Unload frm
          Set frm = Nothing
         Next frm
    End
End Sub

a mixture of the posts, i'm am planning on trying .net if i can get an educational copy from college, otherwise I cant afford to use it.

  • 0
  area91 said:
Try using .net. Its much, much better.

yeah thats going ot help him with his project :rolleyes:. He chose VB6 and that's what he wants help with. If you can't offer help, don't just go throwing out what else to use. It's useless to the thread starter.

btw, I think weenur is right.

  • 0

Hi

Found this somewhere on the web, and it works on my VB6-applications.

Using the Close Button

This is extremely easy, but something you just can't seem to put your finger on.

Here is the code for knowing when that little X is pushed. It should be self-explainatory!

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)

End

End Sub

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.