我在做记事本 退出时判断是否保存。点右上角的关闭用的是 Form_QueryUnload
菜单里的退出按纽用的是quit_Click
但在quit_Click事件发生时 也伴随着Form_QueryUnload事件,请问怎么解决。
在quit_Click事件中调用QueryUnload成功不了
[此贴子已经被作者于2005-6-1 21:14:46编辑过]
Private strfilename As String Private a As Boolean Private b As Integer Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) If a = True Then b = MsgBox("文件已经改变是否保存?", vbYesNoCancel + vbQuestion, "question") Select Case b Case 6 Call saveas_Click Cancel = 0 Case 2 Cancel = 1 Case 7 Cancel = 0 End Select End If End Sub
Private Sub Form_Resize() rtxt.Top = 0 rtxt.Width = Me.Width - 100 rtxt.Height = Me.Height - 1000 End Sub
Private Sub new_Click() '新建 rtxt = "" End Sub
Private Sub open_Click() '打开 With cmdlog .DialogTitle = "打开 open " .Filter = "文本文件 *.txt|*.txt|word文档 *.doc|*.doc|所有文件|*.*" .ShowOpen strfilename = .FileName rtxt.LoadFile strfilename End With End Sub
Private Sub quit_Click() '退出 If a = True Then b = MsgBox("文件已经改变是否保存?", vbYesNoCancel + vbQuestion, "question") Select Case b Case 6 Call saveas_Click Unload frm Case 7 Unload frm End Select Else Unload frm End If End Sub
Private Sub rtxt_Change() 'richtestbox a = True End Sub
Private Sub saveas_Click() '另存 With cmdlog .DialogTitle = "另存为" .Filter = "文本文件 txt|*.txt|word文档 doc|*.doc|所有文件|*.*" .ShowSave strfilename = .FileName rtxt.SaveFile strfilename, 1 End With End Sub