IMAQError Event

NI Vision for Visual Basic

IMAQError Event

Syntax

Sub ControlName_IMAQError(StatusCode, ContextID, ContextDescription)

Applies To

CWIMAQ

Purpose

Fires when an NI-IMAQ error occurs, depending on the value of the ErrorEventMask property. The ErrorEventMask property selects the contexts—configuring, reading data, and so on—for which the CWIMAQ control generates IMAQError events.

Remarks

You can write a global error handler for the CWIMAQ control in the event handler for IMAQError. For example, you can compare the ContextID parameter to the CWIMAQErrorContexts constants in the event handler code to handle errors in certain contexts only.

The value of the ErrorEventMask property determines the contexts for which CWIMAQ generates error events. Typically, you use the IMAQError event only to catch errors while an acquisition is in progress. When configuring, starting, stopping, or resetting an acquisition, you typically test the return value of the CWIMAQ control methods to detect errors. If ExceptionOnError is True, the methods raise an exception on an error condition.

Parameters

StatusCode As Long

The status code for the error.

ContextID As Long

Identifies the context of the error. The CWIMAQErrorContexts constants define the possible values for this parameter.

ContextDescription As String

A textual description of the context.

Example

Private Sub CWIMAQ1_IMAQError(ByVal StatusCode As Long, ByVal ContextID As Long, ByVal ContextDescription As String)
    If ContextID = cwimaqAcquiring Then
        MsgBox ContextDescription & vbCrLf & CStr(StatusCode)
    End If
End Sub

See Also

IMAQWarning

CWIMAQErrorContexts

ErrorEventMask

ExceptionOnError