User`s guide
Modifying Flags
3-17
Handle_Error:
MsgBox(Err.Description)
End Sub
This example converts var1 of type Variant/Integer to an int16 and var2 of
type
Variant/Double to a double. If the original MATLAB function expects
doubles for both arguments, this code might cause an error. One solution is to
assign a
double to var1, but this may not be possible or desirable. In such a
case set the
CoerceNumericToType flag to mwTypeDouble, causing the data
converter to convert all numeric input to
double. In the previous example,
place the following line after creating the class and before calling the methods.
aClass .MWFlags.DataConversionFlags.CoerceNumericToType =
mwTypeDouble
The InputDateFormat flag controls how the VBA Date type is converted. This
example sends the current date and time as an input argument and converts it
to a string.
Sub foo( )
Dim aClass As mycomponent.myclass
Dim today As Date
Dim y As Variant
On Error Goto Handle_Error
today = Now
Set aClass = New mycomponent.myclass
aClass. MWFlags.DataConversionFlags.InputDateFormat =
mwDateFormatString
Call aClass.foo(1,y,today)
Exit Sub
Handle_Error:
MsgBox(Err.Description)
End Sub
The next example uses an MWArg object to modify the conversion flags for one
argument in a method call. In this case the first output argument (
y1) is
coerced to a
Date, and the second output argument (y2) uses the current default
conversion flags supplied by
aClass.