2009/11/06

'error handling easy... (Try-Catch for VB)

'error handling easy... (Try-Catch for VB): "VBScript example:

Option Explicit

Dim nTest

With New Try: On Error Resume Next
nTest = 1 / 0 'Division by zero
.Catch: On Error GoTo 0: Select Case .Number
Case 11
MsgBox .Description
End Select: End With


Class Try '*** programmed by Robert Einhorn, Budapest, 2008 ***
Private mstrDescription
Private mlngHelpContext
Private mstrHelpFile
Private mlngNumber
Private mstrSource

Public Sub Catch()
mstrDescription = Err.Description
mlngHelpContext = Err.HelpContext
mstrHelpFile = Err.HelpFile
mlngNumber = Err.Number
mstrSource = Err.Source
End Sub

Public Property Get Source()
Source = mstrSource
End Property

Public Property Get Number()
Number = mlngNumber
End Property

Public Property Get HelpFile()
HelpFile = mstrHelpFile
End Property

Public Property Get HelpContext()
HelpContext = mlngHelpContext
End Property

Public Property Get Description()
Description = mstrDescription
End Property
End Class"

追蹤者

關於我

提供香港新界大埔區中、小學和幼兒園褓母車接送及機場接載服務。歡迎來電查詢!