我想在单击关闭按钮的时候,响应一个事件,判断是否要退出,不的话,则仍运行原窗体,行不?

解决方案 »

  1.   

    将事件处理的代码写入Form_QueryUnload中
    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
       
    End Sub
      

  2.   

    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
       aa=msgbox ("asdasd",vbyesno,"aa111")
    if aa<>vbyes then
    cancel=true
    else
    unload me
    endif
    End Sub
      

  3.   

    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
        If MsgBox("确定要退出?", vbOKCancel, "系统提示") = vbCancel Then
            '选择了“取消按钮”
           Cancel = True
        End If
    End Sub
      

  4.   

    Private Sub Form_Unload(Cancel As Integer)
       aa=msgbox ("asdasd",vbyesno,"aa111")
    if aa<>vbyes then
    cancel=true
    else
    unload me
    endif
    End Sub
      

  5.   

    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
        If MsgBox("确定要退出?", vbOKCancel, "系统提示") = vbCancel Then
            '选择了“取消按钮”
           Cancel = True
        End If
    End Sub