I agree with Thread1. If there is a need for a form to call an object in another form, programmer must explicitly define a way so that the calling form first check if the owner of the object to be called is loaded or not.
I am inviting you to join GreenZap. It is just like PAYPAL but it is more rewarding! You get $25 when you join (FREE to sign up) AND you get rewarded also when someone opened an account using your GreenZap promo code! GreenZap is launching June 1st.
Oddly enough, I've seen cases where a simple single-form program won't completely unload on a system running winME, but on other OS's it's ok. I used End as the last line of code after the form unloads, which seems to have solved the problem.
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
Cimperiali
Yes, I know that using End isn't supposed to be good, but when you do a test like the following and the program stays in memory (seen in task manager), what then?
Code:
'absolutely no code whatsoever. just a blank form.
'No objects of any kind. No controls either.
A totally blank form compiled into an exe stays running on winME only.
So, I tried "Unload Me" and of course that didn't work. Using End in the Form_Unload sub did the trick. Sure it just terminates the program, but if it's used AFTER everything has been handled the right way anyway, then I would think it wouldn't be so bad.
Basically, I did it this way:
Code:
Private Sub Form_Unload(Cancel As Integer)
'set all objects to nothing
'unload any forms still loaded
End
End Sub
Since the form is unloading at this point anyway, what's left but to terminate?
If there's a better way to do it I'd sure like to know, as I didn't want to use End either.
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
I have alwasy been a major opponent of using the END statement. However, I will have to agree with WizBang on this one. The program I wrote for our company had nothing but problems on Windows ME. Out of memory errors, stack overflow, and just plain not ending properly. Things worked fine on all our 98/2000 systems. For us it was an easy decision to spend the money and upgrade to 2000. Unfortunately, this can't always be done. My suggestion is that in your VB apps, you state that will run on 98/200/XP. Leave ME out of it. But if you have to put your app on ME. please, by all means use the END.
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).
Btw, Wizbang: "unless on buggy Os" =that was exactly for Windows Me,
a horrible one that I remember only for bugs...
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
It seems like the original coder failed to apply any " Exit Do " statement's
within your Looping structure's
Apply : " Exit Do " ' in your Loop's < This should basically be your pivot point ,
Code:
If Button = 1 then
Exit Do
End If
Apply : " Do Events "' Between your Loop's < this will allow Windows to destroy
' Your program during the Unload Event
The use of " End " in the Unload Event just forces Windows to crash exit the application , leading to an internally messy destroy .
If there is any Blitting then more than likely the original coder failed to include the necessary " Destroy DC " , in which case Windows is still trying to write into memory .
Really just guessing here , don't really know what the structure is.....
How can anyone sell information when all the information that they sell is free at the library ?
How come Doctors keep getting smarter yet they cannot cure the common cold ?
If Scientist are right and man evolved from monkey then where did the monkeys' come from ?
Man I love this little dude that waves => <= He just doesn't stop
Bookmarks