0

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!

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by kinwang2009
0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.