Solved

Closing app programmatically

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now