-
I have an application in which if I close it using a button with the following code closes properly.
Private Sub exit_Click()
Dim sMsg As String
Dim nButtons As Integer
Dim nResult As Integer
'
sMsg = "Are you sure you want to exit?"
nButtons = vbYesNo + vbQuestion
nResult = MsgBox(sMsg, nButtons, APP_Title$)
'
If nResult = vbYes Then
'
End
'
End If
'
g_exit_pressed = False
End Sub
If I close it using the X in the corner of the window then check NT Task manager, the program is still running.
Anyone Help????
Thanks
Neil
-
<?>
you could remove the X by setting the ControlBox to false
or you could just call your sub from the query unload event and terminate event of your form.
-
Maybe this will help your proplem with closing when you pressing the (X) button.
Code:
Private Sub Form_Unload(Cancel As Integer)
Dim sMsg As String
Dim nButtons As Integer
Dim nResult As Integer
sMsg = "Are you sure you want to exit?"
nButtons = vbYesNo + vbQuestion
nResult = MsgBox(sMsg, nButtons, App.Title)
If nResult = vbYes Then
End
Else
Cancel = -1
End If
End If
-
Try putting the code in Form_QueryUnload or in Form_Unload. And in the exit button:
Code:
Private Sub exit_Click()
Unload Me
End Sub
Unload Me will trigger the Form_QueryUnload and Form_Unload events.
-
Many Thanks All.
Thats sorted the problem.
Cheers