ExceptionOnError Property
Syntax
CWIMAQ.ExceptionOnError
Data Type
Purpose
Error handling. Set this property to True to specify that the control methods generate an exception on an error condition. Set this property to False to specify that the control methods return a negative number to indicate the error.
Remarks
A method can indicate an error in one of three ways. If ExceptionOnError is True, the method generates an exception. If ExceptionOnError is False, a negative number indicates that the method returns an error. The CWIMAQ control can generate the IMAQError event, depending on the value of the ErrorEventMask.
Some methods return a positive number to indicate a warning. A method returns a warning even if ExceptionOnError is True. You also can use the IMAQWarning event to write a global warning handler.
In Visual Basic, the Err object holds information about the error. In Visual C++, CWIMAQ throws a COleDispatchException.
Example
'When ExceptionOnError is False, CWIMAQ methods return the error code. CWIMAQ1.ExceptionOnError = False Text1.Text = CWIMAQ1.AcquireImage 'When ExceptionOnError is True, CWIMAQ methods raise an exception if an error occurs. CWIMAQ1.ExceptionOnError = True CWIMAQ1.AcquireImage 'If an error occurs then a message box will automatically be displayed by Visual Basic 'In VB use On Error to process the error yourself