Link to home
Start Free TrialLog in
Avatar of KJones
KJones

asked on

Closing app programmatically

I am trying to close my app using "unload Me" in the last line of code, but this causes an application error in NT. When the same code is attached to a button on-click event it works fine.
What am I doing wrong? Or is there a better way of closing without user input?
Avatar of RUSH
RUSH

I've had the same problem before.

The only explanation that I could attribute this to that I was trying to unload the app while process' were still active.

And like your example the same code in the click event of a command button worked fine.

So I used a "work around".
1)Put the "unload me" code in the click event of a command button.
2)Remove the "unload me" code from your last line.
3)Add the code "form.command = true" to your last line.

This should "auto-click" the exit button for you.

I hope this helps.
Rush


Avatar of KJones

ASKER

I appreciate your reply, but unfortunately I get the same result - an application error. It works when I run it within VB but its when I run it as an exe the error occurs.
I'm sure you're right when you say its something still open, but I only have two buttons, a text box and the inet control on the form. Press button 1, download some files and then shut itself down, but (you know the rest..). Button 2 just does the unload me for testing purposes.
Once again thanks for your suggestion.
Just a couple of suggestions,

1)Try it on a Win95 machine to see if it is NT specific.
2)If it is a 16 bit app, run in its own memory space.
3)Try adding a delay before the unload.
 
ASKER CERTIFIED SOLUTION
Avatar of prozak
prozak

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial