Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

How to detect application exiting in VB

  • 17-04-2010 10:11am
    #1
    Closed Accounts Posts: 324 ✭✭


    Hi
    Does anybody know how to detect when a program exits in visual basic?
    The program I'm doing is a console application in windows. It's just an .exe file that runs and prints some things to the console and then finishes.

    I managed to detect when the console is closed with Control-C etc but what I really need is to detect when the actual program exits, like if there is a null pointer exception, and the program completely bombs out. Also the program can be called by other applications so it doesn't always run in a console.
    I've had a look for different events in visual basic on the web but most of them are for Application.Exit which I think is the event for a dialog when you click the X button..
    thanks


Comments

  • Registered Users, Registered Users 2 Posts: 9,579 ✭✭✭Webmonkey


    Can you catch these exceptions with try/catch blocks...not fully familar with VB unfort.


  • Registered Users, Registered Users 2 Posts: 5,401 ✭✭✭DublinDilbert


    I'm not sure about in VB, but one thing that i've done in the past is run the console application and re-direct its output to a text file (using the ">>" operator in dos), then you can read the text file and see what the application has done.


  • Closed Accounts Posts: 324 ✭✭radioactiveman


    Hi
    Thanks, in the end I just caught all of the possible exceptions and called a cleanup function so that the application would not just end immediately.

    I couldn't find a way anywhere to detect if the application was exiting - or the windows event and how to detect it..
    anyway not a bad solution - thanks


Advertisement