Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e _
As System.Windows.Forms.FormClosingEventArgs) Handles _
MyBase.FormClosing
' If validation failed cancel the Closing event.
If Me.Validate = False Then
e.Cancel = True
End If
End Sub