user225269
user225269

Reputation: 10893

Execute a line of code when the user clicks on the close button in vb.net

I have this code that tries to kill the wampmanager process when the user press on a button. But how can I achieve the same thing if the user clicks on the close button. Is it possible to execute a small line of code just when the user clicks on the close button? If you know any alternatives in achieving this, please do tell. thanks

  Dim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName("wampmanager")

            For Each p As Process In pProcess
                p.Kill()
            Next

Upvotes: 0

Views: 598

Answers (1)

Shoban
Shoban

Reputation: 23016

you can use the FormClosing event for that. You can have a common function and call them in button Click and this event.

Upvotes: 1

Related Questions