Good day folks,

I just wanna ask what event should I used to detect when a
form is closed unexpectedly.

I want to update the Log In status of a user in my database
from 'Logged In' to 'Log Out' whenever a form closes the
form unexpectedly or not.

Example, I close the form using task manager. How would I trigger
form closing event?

Member Avatar for Rahul47

You can use FormClosing event in this scenerio, you can find it in event list.

4ca5556f55a6f028a4c63e7f46537b2e

Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        ' Do what you want to do.
End Sub

agree with Rahul47...

@Rahul47,
Can you tell mw how you add the image in the comment box,?
Please

Member Avatar for Rahul47

4254ca2773a68a5e8a061b3e2397457f

11e2245793512a1fbde4dedfeed2bbc5

7d8e14fdb2ae6671b84cf0d0ff543e17

5) You will get something like this --> ![7d8e14fdb2ae6671b84cf0d0ff543e17](/attachments/large/4/7d8e14fdb2ae6671b84cf0d0ff543e17.jpg "7d8e14fdb2ae6671b84cf0d0ff543e17")

Dont worry and submit your reply.

I hope you enjoyed.

commented: Thank you dude... +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.