Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If MsgBox("是否要退出?", vbOKCancel, "提示") = vbOK Then
Cancel = 0
Else
Cancel = 1
End If
End SubPrivate Sub CmdExit_Click()
Unload Me
End SubPrivate Sub CmdMsg_Click()
Unload Me
frmmain.Show
End Sub如何在CmdMsg_Click事件中中调用Form_QueryUnload事件下的判断语句
Private Sub CmdMsg_Click()
Form_QueryUnload
……
End Sub
选OK运行下一步
NO返回,什么也不发生
cancel An integer. Setting this argument to any value other than 0 stops the QueryUnload event in all loaded forms and stops the form and application from closing. unloadmode A value or constant indicating the cause of the QueryUnload event, as described in Return Values.
Return ValuesThe unloadmode argument returns the following values:Constant Value Description
vbFormControlMenu 0 The user chose the Close command from the Control menu on the form.
vbFormCode 1 The Unload statement is invoked from code.
vbAppWindows 2 The current Microsoft Windows operating environment session is ending.
vbAppTaskManager 3 The Microsoft Windows Task Manager is closing the application.
vbFormMDIForm 4 An MDI child form is closing because the MDI form is closing.
vbFormOwner 5 A form is closing because its owner is closing.
cancel An integer. Setting this argument to any value other than 0 stops the QueryUnload event in all loaded forms and stops the form and application from closing. unloadmode A value or constant indicating the cause of the QueryUnload event, as described in Return Values.
Return ValuesThe unloadmode argument returns the following values:Constant Value Description
vbFormControlMenu 0 The user chose the Close command from the Control menu on the form.
vbFormCode 1 The Unload statement is invoked from code.
vbAppWindows 2 The current Microsoft Windows operating environment session is ending.
vbAppTaskManager 3 The Microsoft Windows Task Manager is closing the application.
vbFormMDIForm 4 An MDI child form is closing because the MDI form is closing.
vbFormOwner 5 A form is closing because its owner is closing.
.......
End If
Unload Me
End Sub这样就行了~~不用调用Form_QueryUnload啊!!
Unload Me
End Sub这样就行了~~不用调用Form_QueryUnload啊!!
我在主窗体FrmMain中点击“更换用户“
要先关闭主窗体,会弹出提示,选择“确定“
关毕主窗体,打开登录窗口
选择“取消“就返回主窗体
问题是,在我点击“更换用户“后
选择“取消“后不仅仅是返回主窗体,
还会打开登录窗口
为什么
unload me
登录。show
end if
If MsgBox("是否要退出?", vbOKCancel, "提示") = vbOK Then
Cancel = 0
登陆.show
Else
Cancel = 1
End If
End SubPrivate Sub CmdMsg_Click()
Unload Me
End Sub写就行了
对不起,我是猜的,如果不对请原谅。