E.cancel loop in Visual basic

vb.net

Solution

Just remove the `Close()` call, since the `Form` is already closing. No need to do that.

Problem

I am making an server control application ( simple with some buttons to start/stop the server ) And when the user wants to close the application there will be prompted an confirm box. ``` Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing Dim response As Integer response = MsgBox("Are you sure you want to stop the server", vbYesNo, "Stop Server ?") If response = vbYes Then Shell("cscript ""stop.vbs""", 1) Close() Else e.Cancel = True End If End Sub ``` That is the code I have now. But when I start the application and close it with the X button or with "Close Window" I will be prompted with the question until I click on no, then it will close. It's a loop and it stops when you first click on yes then on no. Can someone help me with solving this ?

Original source