Private Sub frmMain_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing If txtAddress.Text = "" Then Application.Exit() Else e.Cancel = True dlgExit.Show() End If End Sub