|
-
Nov 6th, 2006, 05:41 AM
#1
Thread Starter
Lively Member
Close an App
hello,
unload me is not sufficent for what I am doing, I really need to replicate the action caused when the user clicks the close "X" at the top right of the form,
is it possible to do this programaticly?
thanks.
-
Nov 6th, 2006, 05:50 AM
#2
Re: Close an App
what does unload me do then?
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Nov 6th, 2006, 05:51 AM
#3
Thread Starter
Lively Member
Re: Close an App
well just ulonads the current app, also i i use unload frm1, unload frm2 etc i dont get the desired effect.
-
Nov 6th, 2006, 06:05 AM
#4
Frenzied Member
Re: Close an App
End will immediately pull the plug on your program.
But it is not a very good way.
You can use Unload for any form, not just the one that is calling it.
-
Nov 6th, 2006, 06:09 AM
#5
Thread Starter
Lively Member
Re: Close an App
End not supported by dll is the error i get, presumably cause its not an exe.?
-
Nov 6th, 2006, 06:17 AM
#6
Re: Close an App
What effect do you want to replicate??
This won't close the form:
VB Code:
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Cancel = 1
End Sub
Is this what you're after? Also, End works also in the IDE.
-
Nov 6th, 2006, 06:28 AM
#7
Thread Starter
Lively Member
Re: Close an App
thanks, but all i am trying to do is programaticly make the app beleive that the user has clicked the close cross.
-
Nov 6th, 2006, 06:35 AM
#8
Re: Close an App
"Unload Me" will do it. It will fire the Query_Unload event:
VB Code:
Option Explicit
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If UnloadMode = vbFormCode Then
MsgBox "Form was closed through the code.", vbInformation
End If
End Sub
-
Nov 6th, 2006, 06:36 AM
#9
Thread Starter
Lively Member
-
Nov 6th, 2006, 06:39 AM
#10
Re: Close an App
Here are some other constants:
VB Code:
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Select Case UnloadMode
Case vbFormControlMenu
MsgBox "Close command from Control menu or X button."
Case vbFormCode
MsgBox "Unload statement from code."
Case vbAppWindows
MsgBox "Windows session ending."
Case vbAppTaskManager
MsgBox "Task Manager close."
Case vbFormMDIForm
MsgBox "MDI parent is closing."
Case vbFormOwner
MsgBox "Owner is closing."
End Select
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|