home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / PVb5.0 / VB / SAMPLES / PGUIDE / ERRORS / ERRORS.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-01-30  |  4.2 KB  |  144 lines

  1. VERSION 5.00
  2. Begin VB.Form frmErrors 
  3.    Caption         =   "
  4.    ClientHeight    =   2670
  5.    ClientLeft      =   1140
  6.    ClientTop       =   1530
  7.    ClientWidth     =   5295
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   2670
  10.    ScaleWidth      =   5295
  11.    StartUpPosition =   3  'Windows Default
  12.    Begin VB.CommandButton cmdMakeError 
  13.       Caption         =   "
  14.       Height          =   375
  15.       Left            =   2760
  16.       TabIndex        =   4
  17.       Top             =   1920
  18.       Width           =   2055
  19.    End
  20.    Begin VB.CommandButton cmdCentral 
  21.       Caption         =   "
  22.       Height          =   375
  23.       Left            =   480
  24.       TabIndex        =   3
  25.       Top             =   1920
  26.       Width           =   2055
  27.    End
  28.    Begin VB.TextBox txtFileSpec 
  29.       Height          =   375
  30.       Left            =   480
  31.       TabIndex        =   2
  32.       Text            =   "*:\error.xyz"
  33.       Top             =   600
  34.       Width           =   3255
  35.    End
  36.    Begin VB.CommandButton cmdInline 
  37.       Caption         =   "
  38.       Height          =   375
  39.       Left            =   2760
  40.       TabIndex        =   1
  41.       Top             =   1320
  42.       Width           =   2055
  43.    End
  44.    Begin VB.CommandButton cmdNone 
  45.       Caption         =   "
  46.       Height          =   375
  47.       Left            =   480
  48.       TabIndex        =   0
  49.       Top             =   1320
  50.       Width           =   2055
  51.    End
  52.    Begin VB.Label Label1 
  53.       Caption         =   "
  54.       Height          =   255
  55.       Left            =   480
  56.       TabIndex        =   5
  57.       Top             =   360
  58.       Width           =   3375
  59.    End
  60. Attribute VB_Name = "frmErrors"
  61. Attribute VB_GlobalNameSpace = False
  62. Attribute VB_Creatable = False
  63. Attribute VB_PredeclaredId = True
  64. Attribute VB_Exposed = False
  65. Option Explicit
  66. Private Sub cmdCentral_Click()
  67.     Dim strErrnum As String
  68.     Dim intErr As Integer
  69.     Dim intReturn As Integer
  70.     On Error GoTo CallFileErrors
  71.     strErrnum = InputBox("
  72. ", "68")
  73.     intErr = Val(strErrnum)
  74.     Err.Raise Number:=intErr
  75.     Exit Sub
  76. CallFileErrors:
  77.     intReturn = FileErrors()
  78.     If intReturn = 0 Then
  79.         Resume
  80.     ElseIf intReturn = 1 Then
  81.         Resume Next
  82.     ElseIf intReturn = 2 Then
  83.         MsgBox "
  84.         End
  85.     Else
  86.         MsgBox "
  87.         Resume Next
  88.     End If
  89.         
  90. End Sub
  91. Private Sub cmdInline_Click()
  92.     Dim blnResult As Boolean
  93.     blnResult = FileExists2(txtFileSpec.Text)
  94. End Sub
  95. Private Sub cmdMakeError_Click()
  96.     Err.Raise Number:=71        ' 
  97. End Sub
  98. Private Sub cmdNone_Click()
  99.     Dim blnResult As Boolean
  100.     blnResult = FileExists1(txtFileSpec.Text)
  101. End Sub
  102. Function FileExists1(filename) As Boolean
  103.     ' 
  104.     FileExists1 = (Dir(filename) <> "")
  105. End Function
  106. Function FileExists2(filename) As Boolean
  107.     Dim Msg As String
  108.     ' 
  109.     On Error GoTo CheckError
  110.         FileExists2 = (Dir(filename) <> "")
  111.         ' 
  112.         Exit Function
  113. CheckError:                 ' 
  114.     ' 
  115.  Visual Basic 
  116.     Const mnErrDiskNotReady = 71, mnErrDeviceUnavailable = 68
  117.     ' vbExclamation, vbOK, vbCancel, vbCritical, 
  118.  vbOKCancel 
  119.     ' 
  120.  VBA 
  121.     If (Err.Number = mnErrDiskNotReady) Then
  122.         Msg = "
  123.         ' 
  124.         If MsgBox(Msg, vbExclamation & vbOKCancel) = vbOK Then
  125.             Resume
  126.         Else
  127.             Resume Next
  128.         End If
  129.     ElseIf Err.Number = mnErrDeviceUnavailable Then
  130.         Msg = "
  131.  " & filename
  132.         MsgBox Msg, vbExclamation
  133.         Resume Next
  134.     Else
  135.         Msg = "
  136.  #" & Str(Err.Number) & " 
  137.         & Err.Description
  138.         ' 
  139.         MsgBox Msg, vbCritical
  140.         Stop
  141.     End If
  142.     Resume
  143. End Function
  144.