关于关闭窗口时的问题

tjwangwei1234 2012-05-17 09:19:20
我想实现关闭一个关闭form1这个事件时,出现msgbox,如果选yes就退出程序,如果选no就隐藏当前窗口,但是我的程序好像没进入if语句,不论写yes还是no都是退出程序
Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Dim message, title As String
Dim style As MsgBoxStyle
Dim response As MsgBoxResult
message = "你是否退出程序执行?"
style = MsgBoxStyle.Question Or MsgBoxStyle.YesNo
title = "msgBox测试"
response = MsgBox(message, style, title)
If response = MsgBoxResult.Yes Then
End
Else
Me.hide()
End If
End Sub
...全文
82 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
蓝海 2012-05-17
  • 打赏
  • 举报
回复
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Dim message, title As String
Dim style As MsgBoxStyle
Dim response As MsgBoxResult
message = "你是否退出程序执行?"
style = MsgBoxStyle.Question Or MsgBoxStyle.YesNo
title = "msgBox测试"
response = MsgBox(message, style, title)
If response = MsgBoxResult.Yes Then
End
Else
e.Cancel = True
Me.hide()
End If
End Sub
zhujiawei7 2012-05-17
  • 打赏
  • 举报
回复
Msgbox算对话款,不算窗体
threenewbee 2012-05-17
  • 打赏
  • 举报
回复
在哪个窗体的代码中,me就代表那个窗体。
tjwangwei1234 2012-05-17
  • 打赏
  • 举报
回复
解决了!哈哈 谢谢~还想请教一下,else语句中me.hide()这行代码,me当前的窗体为什么不是Msgbox,是因为Msgbox不算窗体么?[Quote=引用 1 楼 的回复:]

VB.NET code
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Dim message, title As String
Dim style As MsgBoxSty……
[/Quote]

16,555

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧