Solved

Closing app programmatically

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

740 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