Main Content

Class MWComplex

The MWComplex class passes or receives a complex numeric array into or from a compiled class method. This class contains four properties/methods:

Property Real As Variant

Stores the real part of a complex array (read/write). The Real property is the default property of the MWComplex class. The value of this property can be any type coercible to a Variant, as well as object types, with the restriction that the underlying array must resolve to a numeric matrix (no cell data allowed). Valid Visual Basic® numeric types for complex arrays include Byte, Integer, Long, Single, Double, Currency, and Variant/vbDecimal.

Property Imag As Variant

Stores the imaginary part of a complex array (read/write). The Imag property is optional and can be Empty for a pure real array. If the Imag property is not empty and the size and type of the underlying array do not match the size and type of the Real property's array, an error results when the object is used in a method call.

Example

The following Visual Basic code creates a complex array with the following entries:

    x = [ 1+i 1+2i
          2+i 2+2i ]
Sub foo()
    Dim x As MWComplex
    Dim rval(1 To 2, 1 To 2) As Double
    Dim ival(1 To 2, 1 To 2) As Double

    On Error Goto Handle_Error
    For I = 1 To 2
        For J = 1 To 2
                rval(I,J) = I
                ival(I,J) = J
        Next
    Next
    Set x = new MWComplex
    x.Real = rval
    x.Imag = ival
        .
        .
        .
    Exit Sub
Handle_Error:
    MsgBox(Err.Description)
End Sub

Property MWFlags As MWFlags

Stores a reference to an MWFlags object. This property sets or gets the array formatting and data conversion flags for a particular complex array. Each MWComplex object has its own MWFlags property. This property overrides the value of any flags set on the object whose methods are called.

Sub Clone(ppComplex As MWComplex)

Creates a copy of an MWComplex object.

Parameters

ArgumentTypeDescription

ppComplex

MWComplex

Reference to an uninitialized MWComplex object to receive the copy

Return Value

None

Remarks

Clone allocates a new MWComplex object and creates a deep copy of the object's contents. Call this function when a separate object is required instead of a shared copy of an existing object reference.