Thursday, October 19, 2006

How to custom define ApplicationExit Event

In the main() method, before calling the application.Start.Run() or Application.Run() methods,
include the following line of code

AddHandler Application.ApplicationExit, AddressOf OnApplicationExit

Include another method in the application as follows

Private Sub OnApplicationExit(ByVal sender As Object, ByVal e As EventArgs)
'your code here.
End Sub
private void OnApplicationExit(object sender, EventArgs e) {
// Your code here.