Hi folks,

I'm wondering how to close a VB6 multiform application using the red x on the main form. There should be a message box that lets the user confirm the exit ( yes ), or ( no ) resume the application.

Thank You!

Hi folks,

I'm wondering how to close a VB6 multiform application using the red x on the main form. There should be a message box that lets the user confirm the exit ( yes ), or ( no ) resume the application.

Thank You!

A nice way to close a form using the red x in a multi form application.

I found it myself. Hope this helps others.

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

' If message box conflicts with other forms.
frm_A_About.Visible = False
frm_B.Visible = False

' Only prompt if the user hits the red X
If UnloadMode = 0 Then
If MsgBox("Are you sure you want to quit?", vbYesNo Or vbQuestion) = vbNo Then Cancel = True
Unload frm_A
Unload frm_B
Unload frm_C
Unload frm_Z

Set frm_A = Nothing
Set frm_B = Nothing
Set frm_C = Nothing
Set frm_Z = Nothing
End If
End Sub

Good job TDuck, thats how you learn. Please mark it as Solved if your problem is solved.
thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.