Biasanya ketika user mengklik tombol close pada form maka form tersebut akan segera menutup. Nah, jika anda ingin menampilkan message box ketika user mengklik tombol close form. Tuliskan kode berikut di event Form_Close:
If MsgBox ("Anda yakin ingin keluar ?", MsgBoxStyle.Information Or MsgBoxStyle.YesNo, "Konfirmasi") = MsgBoxResult.Yes Then e.Cancel = False Else e.Cancel = True End If