请问编好的程序点击窗口右上角的(X)程序就自动立刻关闭。如何在点击(X)时加以判断询问该是否退出该程序??????

解决方案 »

  1.   

    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    If MsgBox("退出该程序?", vbYesNo + vbQuestion) = vbNo Then
     Cancel = True
    End If
    End Sub
      

  2.   

    Private Sub Form_Unload(Cancel As Integer)
      If MsgBox("退出该程序?", 256 + 4 + 64) = vbNo Then
        Cancel = True
      End If
    End Sub
      

  3.   

    Private Sub Form_Unload(Cancel As Integer)
      If MsgBox("退出该程序?",vbYesNo) = vbNo Then
        Cancel = True
      End If
    End Sub
      

  4.   

    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    If MsgBox("退出该程序?", vbYesNo + vbQuestion) = vbNo Then
     Cancel = True
    End If
    End Sub
      

  5.   

    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
            If MsgBox("确定退出?", vbYesNo, Me.Caption) = vbNo Then
                Cancel = -1
            End If
    End Sub