Hello,
How can I close a program by clicking the x on a dialog box? 'msgbox' what can go after that to make this possible?
Thank you.
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
VulpesRank #55 · 29.2K reputationPosted Mar 10, 2014, 3:54 PM EDT
In the case of other combinations (Yes/No or Abort/Retry/Ignore) you'll find that the X button is disabled.
So, if you want to close the program when the X button on a MsgBox is pressed, you could write code like this:
If it's a console application rather than a Windows Forms application, then replace Application.Exit() with Environment.Exit(1).
Note that there's no way to distinguish between pressing the Cancel button or the X button in the above code.
Rich17 reputationPosted Mar 11, 2014, 5:12 AM EDT
Just to update, I used a little of the example code and typed it up and it does exactly what I want it to do. My program isn't for a desktop or laptop pc, an old PDA. Since I used basic code to create a space shooter, I wasn't able to loop it. So I thought instead of having to tap x and then press a button to do a application.exit command to remove it from RAM, a simple tap the x on the dialog box is a simplier, and quicker way of loading it again.
Thank you.