User`s guide

Modifying F lags
var1(1,2) = 12#
var1(2,1) = 21#
var1(2,2) = 22#
x(1,1) = 11
x(1,2) = 12
x(2,1) = 21
x(2,2) = 22
var2 = x
Set aClass = New mycomponent.myclass
Call aClass.foo(1,y1,var1)
Call aClass.foo(1,y2,var2)
Exit Sub
Handle_Error:
MsgBox(Err.Description)
End Sub
Here, two Variant variables, var1 and var2 are constructed with the same
numerical data, but internally they are structured differently:
var1 is a
2-by-2 array of
Variants with each element containing a 1-by-1 Double,while
var2 is a 1 -by-1 Variant containing a 2-by-2 array of Doubles.
According to the default data conversion rules listed in COM VARIANT to
MATLAB Conversion Rules,
var1 converts to a 2-by-2 cell array with each
cell occupied by a 1-by-1
double,andvar2 converts directly to a 2-by-2 double
matrix.
The
InputArrayFormat flag controls how arrays of these two types are
handled. The two arrays convert to double matrices because the default value
for the
InputArrayFormat flag is mwArrayFormatMatrix. Thi s de fault is used
because array data originating from Excel ranges is always in the form of an
array of
Variants(likevar1 of the previous example), and MATLAB functions
mostoftendealwithmatrixarguments.
But what if you wa nt a cell array? In this case, you set the
InputArrayFormat
flag to mwArrayFormatCell. Do this by adding the following line after creating
the class and before the method call:
aClass .MWFlags.ArrayFormatFlags.InputArrayFormat =
mwArrayFormatCell
2-15