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?

Recommended Answers

All 3 Replies

Member Avatar for Rahul47

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


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...

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

Member Avatar for Rahul47




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.