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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
RichPosted Mar 11, 2014, 9:12 AM
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.
VulpesPosted Mar 10, 2014, 7:54 PM
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.