How to cease all activity on a form
WinXP/VB6Pro ... My app is a game. You fill out your game options on one form, then play on another. When the game is over I would like all code processing on the second form to cease immediately (as opposed to finishing any current procedures). I tried 'Unload me' (with 'Set Form1=nothing in the Unload event) at the point where I want this to occur; the form hides, but the code continues processing. Is there a way to do this cleanly, or is it considered bad coding to even need to? I'd like the code to just stop, and unload the form (so it can be reset for the next game).
Any help or advice appreciated!
Shannon
[656 byte] By [
Shannon] at [2007-11-11 8:48:01]

# 1 Re: How to cease all activity on a form
Just unloading the form won't be enough I think. If your code keeps running you'll get perhaps an error. Maybe you can solve the problem with a public Boolean, a switch who stops the code.
Example:
Public blnStop as boolean
private sub Form_Load()
blnStop = false
working
end sub
private sub Working()
if blnStop = true then exit sub 'Here you can add code when program has to be stopped
textbox1.text = "hello"
end sub
private cmdStop_click()
blnStop = true
end sub
Hope this gives you an idea.
Benjamin
# 2 Re: How to cease all activity on a form
So you are trying to unload the the form you play the game on but keep the settings one open?
Well then the best method is what I think you have already done:
unload form
set form = nothing
If this is what you are you doing, then is this from the game or the settings form? Also what coding is already running when you try?
And yes, it is bad practice to just halt everything, the best practice is to mke sure everything is done and then close the form, which is what unload does ... it ties up all the loose ends, etc
Hope this is of help to you :)
# 3 Re: How to cease all activity on a form
Thanks guys. I rewrote the way I close out the code (on the game form) and just hid the game form until it finished out its threads (is that the right term?). Part of that was reloading the options form. I then had the options form unload the game form once it 'activated'. It seems to be working properly for the first time. :)
Thanks both for suggestions.