-
Jan 10th, 2021, 09:23 AM
#1
Thread Starter
PowerPoster
VB6 - how terminate an infinite loop after close the window?
when we close the window, when we have an infinite loop, the window is closed, but the program stays on memory and the execution isn't terminated.
when we close the window, when we have an infinite loop, how can we terminate that loop?
-
Jan 10th, 2021, 09:37 AM
#2
Re: VB6 - how terminate an infinite loop after close the window?
Code:
Private mClosed As Boolean
Private Sub Form_Load()
Me.Show
Do
DoEvents
If mClosed Then Exit Do
Loop
End Sub
Private Sub Form_Unload(Cancel As Integer)
mClosed = True
End Sub
-
Jan 10th, 2021, 09:44 AM
#3
Thread Starter
PowerPoster
Re: VB6 - how terminate an infinite loop after close the window?
the rate was for be 'thank you so much'... sorry only be 'tk'...
thank you so much for all...
i was severy confused on what event was activated when we close the window... so it's 'unload' event.
i belive the manual connects the close window button to 'Terminate' event.. but it's wrong.
yes some VB6 events have problems... like get\lost focus window events.
thank you so much for all
-
Jan 10th, 2021, 10:03 AM
#4
Re: VB6 - how terminate an infinite loop after close the window?
There is also another event that is the QueryUnload event.
Load/QueryUnload/Unload events are related to the GUI (graphical user interface) elements, ie: the window - the form.
Initialize/Terminate events are related to the code module (to module level variables, their states)
-
Jan 10th, 2021, 10:10 AM
#5
Re: VB6 - how terminate an infinite loop after close the window?
if you are using DirectX remember to have double loop and error exit-codes.
I use:
Code:
Do While Running = 0
Do While Running = 0
- code -
DoEvents (or PeekMessage)
Loop
- code if error, where u could re-enter the loop or exit it -
Loop
- termination procedures (unload, hooks etc)
- end
so while Running is 0, it will continue looping
running can be used for error-coding or if the user clicking on any exit button.
-
Jan 10th, 2021, 10:25 AM
#6
Thread Starter
PowerPoster
Re: VB6 - how terminate an infinite loop after close the window?
i'm sorry, but why 2 loops?
-
Jan 10th, 2021, 10:45 AM
#7
Re: VB6 - how terminate an infinite loop after close the window?
I wrote it: if u use DirectX.
if you have your code running, and u exit to the login screen, and u enter again, all assets will be lost, and u need to reload the assets again or it will crash.
I have a On Error GoTo error, in my rendering function, and if theres an error it will exit the loop.
there I will reload the assets and re-enter the loop.
-
Jan 10th, 2021, 10:50 AM
#8
Thread Starter
PowerPoster
Re: VB6 - how terminate an infinite loop after close the window?
now i get it
thanks for all.. thank you
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
|