-
April 24th, 2004, 03:07 PM
#1
Closing program trouble.
HY!
My program works with access files *.mdb. Everything is working, but when i push the close button the program close itself, but it remains in memory (i can see this when i press Ctr+Alt+Del). My program is working on WinXP. The close button's code is Unload Me. What can be the problem?
-
April 24th, 2004, 06:33 PM
#2
send some code please
are you sure that ALL forms were unloaded not just hidden ?
I a form is still loaded the App. won't close.
-
April 24th, 2004, 06:46 PM
#3
Yep, i've checked
I've double checked. All the forms have only one exit button and they all have tis kind of code:
Private Sub exit_Click()
Unload Me
End Sub
Even if i start the aplication and click the exit button it still remains hidden in process bar.
-
April 24th, 2004, 06:58 PM
#4
Does the form it use an activeX control that does not anload ? (happens if a bug in the control causes it not to terminate).
Do you access the database over a slow network so it takes time to close the connection ?
-
April 24th, 2004, 07:05 PM
#5
no activex or slow network
I'm not using any activex neither access over a network. The database files are access files (mdb). I think that the problem comes from there somewhere, a connection to that database is not closed, but the forms that work with the database are created automatic by the VB6 wizzard.
-
April 24th, 2004, 07:53 PM
#6
Do forms reference each other? You could have a chain of circular references.....
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
April 24th, 2004, 08:19 PM
#7
I have a main form within i call several other forms. I'm using variabiles from one form in another form. I don't know if that can generate circular references.
-
April 24th, 2004, 08:46 PM
#8
Unload me isn't closing the whole app..
Add to your Exit Button the Code:
Exit() (or something like that) and your program will close without you having to think about any forms that may be still open
greetings UNI
-
April 25th, 2004, 01:40 AM
#9
In query_unload of your main form add this code:
Code:
'Private sub Query_Unload(....)
dim frmX as form
For each frmX in Forms
If frmX.Hwnd<> Me.Hwnd then
Unload frmX
end if
Next
dim sMessage as string
If Forms.Count>1 then
For each frmX in Forms
If frmX.Hwnd<> Me.Hwnd then
sMessage =sMessage & frmX.Name & " "
end if
Next
Msgbox "Something made " & sMessage & " not closing correctly"
end if
'End Sub
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
-
April 25th, 2004, 03:26 AM
#10
Originally posted by Illuvatan
Unload me isn't closing the whole app..
Add to your Exit Button the Code:
Exit() (or something like that) and your program will close without you having to think about any forms that may be still open
greetings UNI
you mean END ?
it's not preferable to call END
from msdn :
Note The End statement stops code execution abruptly, without invoking the Unload, QueryUnload, or Terminate event, or any other Visual Basic code. Code you have placed in the Unload, QueryUnload, and Terminate events of forms and class modules is not executed. Objects created from class modules are destroyed, files opened using the Open statement are closed, and memory used by your program is freed. Object references held by other programs are invalidated.
-
April 25th, 2004, 04:44 AM
#11
Success
For the last 3 posts:
1) The Exit commands didn't help. I think that this command only interrupts a for, if, or sub execution without doing anythig else.
2) I'm not quite sure where to put that code. I've put it in the exit sub of the main form. Did i do good?
Putting the code in the exit sub didn't display any messages but also stopped from closing my application. I guess smthin' wrong.
3) An the last but not least and also THE SOLUTION were these three "magic" letters: END . I've commented the Unload Me and the code from Cimperiali and writted the END statement. My exit sub looks like this now:
Private Sub Iesire_Click()
End
End Sub
So i think that the problem is solved and i thank to all who helped me.
-
April 26th, 2004, 06:02 AM
#12
End - abrubpty terminate program
as hspc stated, End is to avoid: it terminates abruptly your code.
Obejcts that need to enter the Terminate_event (or even the
Unload_ procedure) to make cleanup, will not enter that code,
thus nothing is correctly cleaned....Better should be to step inside
code and try to understand what is going wrong (there is always
a "why" if a program does not really stop...). You may think you
have solved, now, and maybe it will work for you. But maybe a
bug will come out soon....
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
-
April 26th, 2004, 06:23 AM
#13
Yes - don't use 'End', especially when working with Access databases.....you could corrupt your database quite easily...
Unloading each of the forms in the forms collection is the correct approach, use the code that Cimperiali has provided - it will work if in the right place & called correctly!
-
April 27th, 2004, 02:46 AM
#14
second thoughts
I guess there is a good reason why my program won't end well when i call the Unload command, but i can't figure it out why...all my forms have the unload command yet the program isn't ending.
Cimperiali gave me a code but i don't know where to put it. Could u give me a little more details, a little project where the code is implementing and working pls?
-
April 27th, 2004, 02:49 AM
#15
Re: send some code please
Originally posted by hspc
are you sure that ALL forms were unloaded not just hidden ?
I a form is still loaded the App. won't close.
what is the 'me' part for in vb? i've seen this alot but i don't have a clue what it's about.
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
|