Originally Posted by cappy2112
Thanks for all the great answers- it looks like End should not be used.
One of The problems with the program I am maintaining is
it has about 10 forms, and the person who wrote it iriginally, never checked for errors during executuion.
This program triggers an oscilloscope through GPIB, and if the scope probe isn't connected securely to a test point, the scope wont trigger. But the code which calls the triggering code, calls it many times.
When the scope doesn't trigger, the users typically exit the program, and restart it. When the user selects Exit from any of the Form Menus this code gets called (which is in a .BAS file)
Sub ProgramEnd(CallingWindowHandle As Long)
Dim Form As Form
' ProgramIsUnloading MUST be set here, or the forms wont be unloaded
ProgramIsUnloading = True
For Each Form In Forms
If Form.hwnd <> CallingWindowHandle Then
Unload Form
End If
Next
end sub
However, even though all of the forms are closed, the code trying to trigger the scope is still running, as verified by task manager.
So when the user runs a second instance of the program ( the old instance is running, but not visible) both programs try to talk to the scope, which results in both programs hanging.
I want to re-write the scope triggering code, so an error is returned, when the scope doens't trigger. However, that's a lot of code, so I was hoping for a quicker fix (like End, or something).