RaiseError Method

NI Vision for Visual Basic

RaiseError Method

Syntax

CWIMAQVision.RaiseError ErrorCode [, Source]

Purpose

Raises the error with the specified error number. The error code must be an error that is returned by some CWIMAQVision or CWIMAQ function. An invalid error code causes Vision to return an unexpected error message.

Parameters

ErrorCode As Long

The error code to raise.

Source As Variant

[Optional] A String indicating the source of the error.

Example

Private Sub Run_Click()
    'Raise an error: "The coordinate system could not be found."
    CWIMAQVision1.RaiseError -31754, "Run_Click"
    
    'Comment out the above line and run again. Because 5 is not a valid CWIMAQ error
    'code, this line will result in an "unexpected error" message.
    CWIMAQVision1.RaiseError 5, "Run_Click"
End Sub