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

How to detect application exiting in VB

Options
  • 17-04-2010 11: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 Posts: 9,579 ✭✭✭Webmonkey


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


  • Registered Users Posts: 5,379 ✭✭✭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