VB.NET中退出确认的实现

VB.NET中退出确认的实现,第1张

概述1、 Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing     If MessageBox.Show("确定退出吗?", "退出确认", MessageBoxButtons.YesNo,

1、
Private Sub Form1_FormClosing(ByVal sender As Object,ByVal e As System.windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
If MessageBox.Show("确定退出吗?","退出确认",MessageBoxbuttons.YesNo,MessageBoxIcon.Question) = windows.Forms.DialogResult.No Then
e.Cancel = True
End If
End Sub

2、
Private Sub Form1_FormClosing(ByVal sender As Object,ByVal e As System.windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
If MsgBox("确定退出吗?",MessageBoxbuttons.OKCancel,"退出确认") = windows.Forms.DialogResult.Cancel Then
e.Cancel = True
End If
End Sub


3、
Private Sub Form1_FormClosing(ByVal sender As Object,ByVal e As System.windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Dim p As Integer
p = MsgBox("你真的要退出游戏吗?",MsgBoxStyle.OkCancel,"游戏提示")
If p = 2 Then
e.Cancel = True
End If
End Sub

4、最简单的代码:
Private Sub Form1_FormClosing(ByVal sender As Object,ByVal e As System.windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
If MsgBox("你确认要退出程序吗?","退出提示") = MsgBoxResult.Cancel Then e.Cancel = True
End Sub

以上只是点击窗口关闭按钮时的用法,若直接在窗体控件上点击退出时,可以用以下方式实现:

Public Sub checkExit() If (MessageBox.Show("您确定要退出系统吗?","确认",MessageBoxIcon.Question) = windows.Forms.DialogResult.OK) Then Me.Close() Application.Exit() End If End Sub

总结

以上是内存溢出为你收集整理的VB.NET中退出确认的实现全部内容,希望文章能够帮你解决VB.NET中退出确认的实现所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1294619.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-10
下一篇 2022-06-10

发表评论

登录后才能评论

评论列表(0条)

保存