【VB开源代码栏目提醒】:网学会员为广大网友收集整理了,Ex7_6.frm,希望对大家有所帮助!
VERSION 5.00
Begin VB.Form Ex7_6
Caption = "Form1"
ClientHeight = 3060
ClientLeft = 60
ClientTop = 450
ClientWidth = 5010
LinkTopic = "Form1"
ScaleHeight = 3060
ScaleWidth = 5010
StartUpPosition = 3 '窗口缺省
End
Attribute VB_Name = "Ex7_6"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Load()
'设窗体相关属性
Ex7_6.Caption = "窗体的载入和卸载"
Ex7_6.Appearance = 0
Ex7_6.Width = 3900
Ex7_6.Height = 3200
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Dim re As Integer
re = MsgBox("你当前想要关闭窗体,是否继续呢?", vbOKCancel, "确定关闭窗体")
If re = 2 Then Cancel = True '终止窗体的卸载
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim Msg, Response ' 声明变量
Msg = "在关闭窗体之前要保存数据吗?"
Response = MsgBox(Msg, vbQuestion + vbYesNoCancel, "保存窗体")
Select Case Response
Case vbCancel ' 不关闭窗体
Cancel = -1
Msg = "操作被取消"
Case vbYes
'这里输入保护数据的代码
Msg = "保存窗体" '
Case vbNo
Msg = "不保存窗体"
End Select
MsgBox Msg, vbOKOnly, "提示" '显示信息
End Sub