Solved

Closing app programmatically

Posted on 1998-11-22
4
214 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 100 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

728 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