Function Fix Ups Class

ComplexStringToReals

"Complex String To Real Numbers" Convert either a real number or a complex number into a complex number. This function considers complex numbers to be represented as strings of the form "R|I" where R is represents the numeric real part of the number and I represents the numeric imaginary part of the number.

Signature (Visual Basic / VBA)

Public Function ComplexStringToReals( _
      ByRef rReal As Variant _
    , ByRef rImag As Variant _
    , ByVal vValue As Variant _
    , Optional ByVal vSupportStringDates As Variant _
    ) As Boolean

Code Example

    Assuming
       Dim varReal As Variant
       Dim varImag As Variant
    for example
       ComplexStringToReals(varReal, varImag, "-1|-2") = True
    leaves
       varReal = -1
       varImag = -2
    also
       ComplexStringToReals(varReal, varImag, 23) = True
    leaves
       varReal = 23
       varImag = 0

Parameters

Parameter Description
rReal Argument whose value is set to the real part of the number vValue.
rImag Argument whose value is set to the imaginary part of the number vValue (if vValue represents a complex number). rImag is set to 0 (zero) if vValue does NOT represent a complex number.
vValue The number whose real and imaginary parts are each returned via separate arguments. Function returns True if vValue has a numeric interpretation. Function returns False if vValue is Null or could not be fixed up to a number.
vSupportStringDates Determines whether the function should consider date strings to represent numbers. Set to True if the function should consider date strings like "4/5/96" to be numbers, or set to False to save time if the function should not have to deal with date strings.

Notes & Version History

Summary If Value is a complex number of the form "R|I" then rReal = R and rImag = I. If Value is a numeric value then rReal = R and rImag = Null. If Value is non-numeric then rReal = Null and rImag = Null.