?
Solved

Closing app programmatically

Posted on 1998-11-22
4
Medium Priority
?
215 Views
Last Modified: 2010-05-03
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?
0
Comment
Question by:KJones
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Expert Comment

by:RUSH
ID: 1446131
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


0
 

Author Comment

by:KJones
ID: 1446132
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.
0
 

Expert Comment

by:RUSH
ID: 1446133
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.
 
0
 
LVL 1

Accepted Solution

by:
prozak earned 200 total points
ID: 1446134
Since you're trying to close you app anyway. Why not just put "End"?

Sub Command1_Click()
  End
End Sub

That should work on any machine. Hope this helps
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month9 days, 22 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question