VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "VB6 例11-14 错误处理"
   ClientHeight    =   3195
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3195
   ScaleWidth      =   4680
   StartUpPosition =   3  '窗口缺省
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Activate()
Print "单击窗体，提示A驱动器未准备好。"

End Sub

Private Sub Form_Click()
    On Error GoTo ErrorHandler
    FileCopy "A:\ Student.mdb ", "C:\ Student.mdb "
    Exit Sub                                ' 正常退出本程序
ErrorHandler:                                   ' 错误处理块入口
    ' 以下语句利用Err对象的属性Number指示的错误号处理出错
    Select Case Err.Number
    Case 53                             ' 出错号53为文件不存在
    Style = vbRetryCancel + vbCritical + vbDefaultButton2
    Response = MsgBox("文件不存在!", Style, Err.Number & "出错")    ' 等待用户处理
    Case 71                             ' 71驱动器未准备好
    Style = vbRetryCancel + vbExclamation + vbDefaultButton2
    Response = MsgBox("A盘未准备好!", Style, "71出错")
    Case Else                               ' 当发生其他不可预知的错误，退出本程序
    MsgBox Err.Number & "出错，退出本程序!"
    End Select
    If Response = vbCancel Then Exit Sub                ' 若按下Cancel按钮，放弃处理
    Resume                              ' Resume再次执行原出错语句

End Sub
