Prevent a Form From Closing in VB.NET

Category:
C#, VB.NET, ASP.NET
Type:
Snippets
Difficulty:
Beginning
Author:
Pankaj Banga

Version Compatibility: Visual Basic.NET

More information:
The Closing event occurs when a Form is being closed. If this event is cancelled, the Form remains open. To cancel the closure of a Form, set the Cancel property of the CancelEventArgs passed to event handler to True, as illustrated by this code.

Instructions: Copy the declarations and code below and paste directly into your VB project.

Declarations:

Code: