Enable or disable error handling by the container of the
control.
Syntax
object.ThrowError = { True | False }
Remarks
Error handling for methods can be done in either of two different
styles, according to the value of this property.
If the ThrowError property is set to False, the application
should check the return value of any method that is used, and report
errors based upon the documented value of the return code. It is the
responsibility of the application to interpret the error code, if it
is desired to explain the error in addition to reporting it.
If the ThrowError property is set to True, then errors
occurring within the control will be thrown to the container of the
control. For example, in Visual Basic 6.0, the On Error
statement is used to establish error handling. Note that if an error
occurs while a property value is being accessed, an exception will
be raised regardless of the value of the ThrowError
property.
Data Type
Boolean
Example
The following example handles errors by checking the return code
of a method:
Dim nError As Long
' The control will not raise an exception when an error occurs
Server1.ThrowError = False
' Start the server
nError = Server1.Start()
' If the method returns an error code, then display a message box
' and exit the subroutine
If nError > 0 Then
MsgBox Server1.LastErrorString, vbExclamation
Exit Sub
Endif
The following example handles errors by generating an
exception:
On Error GoTo Failed
' The control will raise an exception when an error occurs
Server1.ThrowError = True
' Start the server
Server1.Start
Exit Sub
' If the method fails, code execution will resume at this label
Failed:
MsgBox Err.Description, vbExclamation
Exit Sub
See Also
LastError Property,
OnError Event
|