|
-
Oct 1st, 2002, 03:35 PM
#1
Thread Starter
Fanatic Member
What is the code to quit my program I created?
I just finished building my application that I built in VB6. I have an Exit button on the main form that unloads the main form. I have Unload me code already. What is the line of code that ends the running of my code?
Last edited by Avatarp; Oct 1st, 2002 at 03:42 PM.
-
Oct 1st, 2002, 03:38 PM
#2
To unload the form you are currently working with, you would use
Unload Me
and generally people like to use this code in the form's unload event to clean up after multiple forms...
VB Code:
Dim frm As Form
For Each frm In Forms
Unload frm
Set frm = Nothing
Next
End
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Oct 1st, 2002, 03:39 PM
#3
Frenzied Member
not sure what you mean
if u mean unload the form just use
Unload Me
:::`DISCLAIMER`:::
Do NOT take anything i have posted to be truthful in any way, shape or form.
Thank You!
--------------------------------
"Never heard about "hiking" poles. I usualy just grab a stick from the nature, and use that as a pole." - NoteMe
"Finaly I can look as gay as I want..." - NoteMe
Languages: VB6, BASIC, Java, C#. C++
-
Oct 1st, 2002, 03:40 PM
#4
Thread Starter
Fanatic Member
I've done that
I have done that already. But VB6 still stays in run mode. So what else do I need to end my run mode?
-
Oct 1st, 2002, 03:41 PM
#5
Frenzied Member
try this
Unload Me
End
usually ppl dont use End, but just try it after the unload me
:::`DISCLAIMER`:::
Do NOT take anything i have posted to be truthful in any way, shape or form.
Thank You!
--------------------------------
"Never heard about "hiking" poles. I usualy just grab a stick from the nature, and use that as a pole." - NoteMe
"Finaly I can look as gay as I want..." - NoteMe
Languages: VB6, BASIC, Java, C#. C++
-
Oct 1st, 2002, 03:43 PM
#6
PowerPoster
Re: I've done that
Originally posted by Avatarp
I have done that already. But VB6 still stays in run mode. So what else do I need to end my run mode?
Read above and you will see the answer has been already posted...
VB Code:
Dim frm As Form
For Each frm In Forms
Unload frm
Set frm = Nothing
Next
End
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Oct 1st, 2002, 03:43 PM
#7
Thread Starter
Fanatic Member
Thanks
End works...LOL that was easy
-
Oct 1st, 2002, 06:20 PM
#8
PowerPoster
Re: Thanks
Originally posted by Avatarp
End works...LOL that was easy
END
This is the most unprofessional, unreliable way of exiting a program...
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Oct 1st, 2002, 06:29 PM
#9
Frenzied Member
Well....
i told him to try Unload Me first, but didnt seem to work for him so i said End
:::`DISCLAIMER`:::
Do NOT take anything i have posted to be truthful in any way, shape or form.
Thank You!
--------------------------------
"Never heard about "hiking" poles. I usualy just grab a stick from the nature, and use that as a pole." - NoteMe
"Finaly I can look as gay as I want..." - NoteMe
Languages: VB6, BASIC, Java, C#. C++
-
Oct 1st, 2002, 07:48 PM
#10
I wonder how many charact
So now we know somethin in the program isn't ending properly... an unreleased resource...
-
Oct 1st, 2002, 07:49 PM
#11
PowerPoster
Well
Originally posted by nemaroller
So now we know somethin in the program isn't ending properly... an unreleased resource...
Huh ?
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Oct 1st, 2002, 07:52 PM
#12
Frenzied Member
Well...
i think hes saying, since Unload Me isnt working... part of the program is still running .....right?
:::`DISCLAIMER`:::
Do NOT take anything i have posted to be truthful in any way, shape or form.
Thank You!
--------------------------------
"Never heard about "hiking" poles. I usualy just grab a stick from the nature, and use that as a pole." - NoteMe
"Finaly I can look as gay as I want..." - NoteMe
Languages: VB6, BASIC, Java, C#. C++
-
Oct 1st, 2002, 09:26 PM
#13
I wonder how many charact
-
Oct 1st, 2002, 09:47 PM
#14
PowerPoster
Well
And using this code doesn't work for you?
VB Code:
Dim frm As Form
For Each frm In Forms
Unload frm
Set frm = Nothing
Next
End
This is how I end all my apps...
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Oct 1st, 2002, 09:58 PM
#15
PowerPoster
If your have more than 1 form still loaded in your project, then you need to unload that as well.
-
Oct 1st, 2002, 09:59 PM
#16
PowerPoster
Well
The code I posted will unload all the forms !!!
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Oct 1st, 2002, 10:05 PM
#17
Frenzied Member
well....
if his app still wasnt ending And he placed teh code in the right place, something was still running
just not sure what tho
:::`DISCLAIMER`:::
Do NOT take anything i have posted to be truthful in any way, shape or form.
Thank You!
--------------------------------
"Never heard about "hiking" poles. I usualy just grab a stick from the nature, and use that as a pole." - NoteMe
"Finaly I can look as gay as I want..." - NoteMe
Languages: VB6, BASIC, Java, C#. C++
-
Oct 1st, 2002, 10:07 PM
#18
PowerPoster
Re: Well
Originally posted by James Stanich
The code I posted will unload all the forms !!!
Yeah.. or you could just do
Unload Form1
Unload Form2.
Alot less code if he only has 2 forms.
-
Oct 1st, 2002, 10:07 PM
#19
PowerPoster
Well
If this code is place in any form in the project, all forms and form levels variables will be destroyed... this would in turn release all memory being consumed, and close the application... I do not understand the argument here...
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Oct 1st, 2002, 10:19 PM
#20
PowerPoster
James is correct. His code will unload all forms and clear up the memory they take, but if there are any loops running, it won't stop them. You will need to stop the loop before you can exit the program and release all the resources it's taking.
-
Oct 1st, 2002, 10:21 PM
#21
PowerPoster
Well
Loops running at time of close? You mean a crash in the loop?
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Oct 1st, 2002, 10:24 PM
#22
PowerPoster
No, I mean if you put in a loop somewhere that is running, say you put this on a form, then try to exit the program using your code, it will close the form, but it will still be in memory:
VB Code:
For I = 0 to 500000000
Debug.Print I
DoEvents
Next
-
Oct 1st, 2002, 10:25 PM
#23
PowerPoster
Well
But wouldn't "i" be terminated, thus terminating the loop?
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Oct 1st, 2002, 10:26 PM
#24
PowerPoster
Nope. Try it. I just did, and it just keeps printing to the debug window, although the app has closed.
-
Oct 1st, 2002, 10:27 PM
#25
PowerPoster
Well
Originally posted by MidgetsBro
Nope. Try it. I just did, and it just keeps printing to the debug window, although the app has closed.
That's amazing. The varaibles should be destroyed but are not. Scary thought....
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Oct 1st, 2002, 10:28 PM
#26
PowerPoster
Because you are just setting the forms to nothing, you aren't setting any variables to nothing. You would have to loop through all your variables you declared earlier in the program and set each one to nothing, if that's even possible.
-
Oct 1st, 2002, 10:29 PM
#27
PowerPoster
Well
Originally posted by MidgetsBro
Because you are just setting the forms to nothing, you aren't setting any variables to nothing. You would have to loop through all your variables you declared earlier in the program and set each one to nothing, if that's even possible.
By setting the form = nothing, I was lead to belive that the form level variables were alos destroyed. Was I mislead?
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Oct 1st, 2002, 10:33 PM
#28
Frenzied Member
ahh
well what would be so bad about using End in this situation?
or couldt it possibly cause an error
:::`DISCLAIMER`:::
Do NOT take anything i have posted to be truthful in any way, shape or form.
Thank You!
--------------------------------
"Never heard about "hiking" poles. I usualy just grab a stick from the nature, and use that as a pole." - NoteMe
"Finaly I can look as gay as I want..." - NoteMe
Languages: VB6, BASIC, Java, C#. C++
-
Oct 1st, 2002, 10:34 PM
#29
PowerPoster
Either that, or the programmers of VB intended for that to happen, but then they never implemented it into the language...
The best way to do this is to check a "Quitting" variable in each loop that might run for any length of time that is user noticable, an if it's set to true in the form_QueryUnload event, then in the loops you can exit the loop if the variable is set to true.
VB Code:
'General Declares
Dim Quitting As Boolean
Dim LoopQuitSuccessful As Boolean
Private Sub EndlessLoop()
Do
Debug.Print "Doing Nothing"
If Quitting Then
LoopQuitSuccessful = True
Exit Loop
End If
DoEvents
Loop
End Sub
Private Sub Form_QueryUnload(Cancel As Integer)
Quitting = True
Do Until LoopQuitSuccessful
DoEvents
Loop
End Sub
Last edited by MidgetsBro; Oct 1st, 2002 at 10:37 PM.
<removed by admin>
-
Oct 1st, 2002, 10:36 PM
#30
PowerPoster
End won't cause an error, but it doesn't free up memory either. It just quits the process, but leaves everything it used, instead of cleaning it up. If the user ends the program like this numerous times in a single session (like if they don't shut their computer down often) then they will run out of resources and be forced to shut down or restart the computer.
-
Oct 1st, 2002, 10:37 PM
#31
PowerPoster
Well
Since we are beating this to death here, what about global variables, is there a proper way of releasing that memory?
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Oct 1st, 2002, 10:39 PM
#32
PowerPoster
Not sure about globals, as I don't use them often, but if you don't set them to nothing, then I assume they will stay in memory as well... *ponders*
-
Oct 1st, 2002, 10:40 PM
#33
Frenzied Member
ooook
oh ok lol
end.Bad = True
:::`DISCLAIMER`:::
Do NOT take anything i have posted to be truthful in any way, shape or form.
Thank You!
--------------------------------
"Never heard about "hiking" poles. I usualy just grab a stick from the nature, and use that as a pole." - NoteMe
"Finaly I can look as gay as I want..." - NoteMe
Languages: VB6, BASIC, Java, C#. C++
-
Oct 1st, 2002, 10:40 PM
#34
PowerPoster
Re: ooook
Originally posted by ice_531
oh ok lol
end.Bad = True
At least someone learned something in all this babble...
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Oct 1st, 2002, 10:43 PM
#35
Frenzied Member
lol
i learn something new every day on this forum
:::`DISCLAIMER`:::
Do NOT take anything i have posted to be truthful in any way, shape or form.
Thank You!
--------------------------------
"Never heard about "hiking" poles. I usualy just grab a stick from the nature, and use that as a pole." - NoteMe
"Finaly I can look as gay as I want..." - NoteMe
Languages: VB6, BASIC, Java, C#. C++
-
Oct 2nd, 2002, 01:24 AM
#36
PowerPoster
Re: Re: ooook
Originally posted by James Stanich
At least someone learned something in all this babble...
I learnt something as well. Don't listen to myself.
-
Oct 2nd, 2002, 04:24 AM
#37
Frenzied Member
Originally posted by MidgetsBro
End won't cause an error, but it doesn't free up memory either. It just quits the process, but leaves everything it used, instead of cleaning it up. If the user ends the program like this numerous times in a single session (like if they don't shut their computer down often) then they will run out of resources and be forced to shut down or restart the computer.
DAMMIT....
No wonder my App keeps freezing me up..
THANKS DOOD!
-
Oct 2nd, 2002, 04:25 AM
#38
Frenzied Member
Also,
i put the code above (for each frm) in my "Unload" statement?
-
Oct 2nd, 2002, 08:07 AM
#39
PowerPoster
Well
What i usually do is create a global sub in a module which when I want to exit any form I call like this
Then the subroutine
VB Code:
Sub GOODEXIT()
Dim frm As Form
For Each frm In Forms
Unload frm
Set frm = Nothing
Next
End
End Sub
Last edited by James Stanich; Oct 2nd, 2002 at 09:33 AM.
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Oct 2nd, 2002, 09:03 AM
#40
Frenzied Member
dont u need
at the top, and
at the bottom?
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
|