Кнопка 2 и кнопка закрытия формы закрывают форму, задавая один и тот же вопрос
Тусклая кнопка2Да как логическое = Ложь
Закрытая вложенная кнопка Button2_Click (отправитель как объект, e как EventArgs) обрабатывает Button2.Click
If MessageBox.Show(" Sure to close? ", "CLOSING CONTROL", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
button2Yes = True
Me.Close()
Else
button2Yes = False
End If
End Sub
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles Me.FormClosing
If Not button2Yes Then
If Not MessageBox.Show(" Sure to close? ", "CLOSING CONTROL", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
e.Cancel = True
End If
End If
End Sub