brainleak
Well-known member
If I click on the x box at the upper right corner of the form to close it, a textbox validating event fires because of missing or wrong data. How can I avoid that?
Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load btnClose.CausesValidation = False End Sub Private Sub TextBox1_Validating(sender As Object, e As CancelEventArgs) Handles TextBox1.Validating If TextBox1.Text = "" Then MsgBox("Don't leave it blank") End If End Sub Private Sub btnClose_Click(sender As Object, e As EventArgs) Handles btnClose.Click Me.Close() End Sub End Class