Leo Bramwell-Speer
2012-08-13 12:53:15 UTC
Hi
It's a single form module in VB6...
-------------------------------------------------------------------------
Option Explicit
Private Quit As Boolean
-------------------------------------------------------------------------
Private Sub Form_Activate()
Do
DoEvents
Line (Rnd * ScaleWidth, Rnd * ScaleHeight)- _
(Rnd * ScaleWidth, Rnd * ScaleHeight), _
RGB(Rnd * 256, Rnd * 256, Rnd * 256)
Loop Until Quit
End Sub
-------------------------------------------------------------------------
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Quit = True
End Sub
-------------------------------------------------------------------------
The form disappears the VB6 IDE hangs in Run mode, yet if I remove the
line of code that draws the lines, it terminates correctly. The only way
of doing it is to add:
-------------------------------------------------------------------------
-Private Sub Form_Unload(Cancel As Integer)
Unload Me
End
End Sub
-------------------------------------------------------------------------
Which apparently is BAAAD, for 2 reasons: 1) The Unload Me statement is
unnecessary as the sub is already doing it? & 2)NEVER USE END as it can
cause memory leaks'n'stuff. I quote from VB6 Help:
'The End statement provides a way to force your program to halt. For
normal termination of a Visual Basic program, you should unload all
forms. Your program closes as soon as there are no other programs holding
references to objects created from your public class modules and no code
executing.'
So what gives? How do I do it properly?
Yours confusedly,
It's a single form module in VB6...
-------------------------------------------------------------------------
Option Explicit
Private Quit As Boolean
-------------------------------------------------------------------------
Private Sub Form_Activate()
Do
DoEvents
Line (Rnd * ScaleWidth, Rnd * ScaleHeight)- _
(Rnd * ScaleWidth, Rnd * ScaleHeight), _
RGB(Rnd * 256, Rnd * 256, Rnd * 256)
Loop Until Quit
End Sub
-------------------------------------------------------------------------
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Quit = True
End Sub
-------------------------------------------------------------------------
The form disappears the VB6 IDE hangs in Run mode, yet if I remove the
line of code that draws the lines, it terminates correctly. The only way
of doing it is to add:
-------------------------------------------------------------------------
-Private Sub Form_Unload(Cancel As Integer)
Unload Me
End
End Sub
-------------------------------------------------------------------------
Which apparently is BAAAD, for 2 reasons: 1) The Unload Me statement is
unnecessary as the sub is already doing it? & 2)NEVER USE END as it can
cause memory leaks'n'stuff. I quote from VB6 Help:
'The End statement provides a way to force your program to halt. For
normal termination of a Visual Basic program, you should unload all
forms. Your program closes as soon as there are no other programs holding
references to objects created from your public class modules and no code
executing.'
So what gives? How do I do it properly?
Yours confusedly,
--
Leo
http://leobs.net/
Leo
http://leobs.net/