MATLAB Excel Builder    

Handling Errors During a Method Call

Errors that occur while creating a class instance or during a class method create an exception in the current procedure. Visual Basic provides an exception handling capability through the On Error Goto <label> statement, in which the program execution jumps to <label> when an error occurs. (<label> must be located in the same procedure as the On Error Goto statement). All errors are handled this way, including errors within the original MATLAB code. An exception creates a Visual Basic ErrObject object in the current context in a variable called Err. (See the Visual Basic for Applications documentation for a detailed discussion on VBA error handling.) All of the examples in this section illustrate the typical error trapping logic used in function call wrappers for MATLAB Excel Builder components.

Modifying Flags

Each MATLAB Excel Builder component exposes a single read/write property named MWFlags of type MWFlags. The MWFlags property consists of two sets of constants: array formatting flags and data conversion flags. The data conversion flags change selected behaviors of the data conversion process from Variants to MATLAB types and vice versa. By default, MATLAB Excel Builder components allow setting data conversion flags at the class level through the MWFlags class property. This holds true for all Visual Basic types, with the exception of the Excel Builder MWStruct, MWField, MWComplex, MWSparse, and MWArg types. Each of these types exposes its own MWFlags property and ignores the properties of the class whose method is being called. The MWArg class is supplied specifically for the case when a particular argument needs different settings from the default class properties.

This section provides a general discussion of how to set these flags and what they do. See Class MWFlags for a detailed discussion of the MWFlags type, as well as additional code samples.


  Processing varargin and varargout Arguments Array Formatting Flags