How do I implement code for ending the programme by clicking the cross at the upper left corner?
Printable View
How do I implement code for ending the programme by clicking the cross at the upper left corner?
I am not exactly sure what you mean, but if you put:
this will close all the componants of the program.Code:End
Using "End" will cause problems. You need to unload all forms and make sure all the objects you've reference or created are set to Nothing.
I must have been misunderstood. I know that unload and end causes the programme to end, but what is the syntax do I use in the Terminat-procedure? I have used the code below, but the programme terminates, when I click the cross and then it asks me if I want to end.
Code:Private Sub MDIForm_Terminate()
Msg = "Do you want to end the calculations?"
Style = 36
Title = "Tester"
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then
End
End If
End Sub
Code:Private Sub Form_QueryUnload (Cancel As Integer, UnloadMode As Integer)
Dim Msg ' Declare variable.
If UnloadMode > 0 Then
' If exiting the application.
Msg = "Do you really want to exit the application?"
Else
' If just closing the form.
Msg = "Do you really want to close the form?"
End If
' If user clicks the No button, stop QueryUnload.
If MsgBox(Msg, vbQuestion + vbYesNo, Me.Caption) = vbNo Then Cancel = True
End Sub