VB本身有form_unload()过程,根据它返回的cancel决定是否退出
你不想退出的话设它为1就可以了。把下面加入form_unload()就可以了
msgbox "信息"
cancel=1

解决方案 »

  1.   

    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
        If MsgBox("要退出么?", vbOKCancel + vbInformation, "系统提示") = vbOK Then
            
        Else
            Cancel = 1
        End If
    End Sub
      

  2.   

    建议用
    Cancel=False
    Cancel=Ture
    来表示,应为更容易理解当然,此处就用Cancel=Ture
    请大家记住True不是等于1的,兄弟们,这可不是开玩笑啊!哈哈
      

  3.   

    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
        If UnloadMode<> vbFormCode Then
            MsgBox "Unload Canceled"
            Cancel=True
        End If
    End Sub
      

  4.   

    你是说要把关闭按钮变灰吗?如果是的话,可以看看我对这篇帖子的回复:http://www.csdn.net/expert/Topic/66946.shtm