P
(PeteCresswell)
I'm calling a routine that does something like:
------------------------------------------------------------
Dim myResult As Variant
myResult = gExcelApp.Run("MDURATION",
mySettlementDate,
myMaturityDate,
theCoupon,
theYieldPercent,
thePaymentFrequencyID_Excel,
theBasisID_Excel
)
------------------------------------------------------------
Works fine most of the time and the "Duration" (a number like
5.7586) gets passed back to the calling routine.
But on some passed arguments, MDURATION chokes and returns an
error that *looks* like a string. e.g. "Error 2036"
And, indeed, I'm able to pass that back up the chain through
the function's Variant return value.
After the func has been called, and I look at the returned value
in the Immediate window, it still looks like a
string: "Error 2036".
The fun comes when I try to do a Debug.Print.
Just printing the variable containing the error works.
viz:
-----------------------------
debug.Print curDuration_Excel
Error 2036
-----------------------------
But when I try to concatenate a string in front of the
variable, it throws an error;
viz:
-------------------------------------------------------
debug.Print "xxx" & curDuration_Excel
(throws Runtime Error 13: Type Mismatch)
-------------------------------------------------------
Same thing if I do a:
?"XX" & curDuration_Excel
Seems like my use of a variant is covering for me most of the
time, but somehow I'm getting caught when I try to concat it with
a string.
Can anybody explain what's going on here?
------------------------------------------------------------
Dim myResult As Variant
myResult = gExcelApp.Run("MDURATION",
mySettlementDate,
myMaturityDate,
theCoupon,
theYieldPercent,
thePaymentFrequencyID_Excel,
theBasisID_Excel
)
------------------------------------------------------------
Works fine most of the time and the "Duration" (a number like
5.7586) gets passed back to the calling routine.
But on some passed arguments, MDURATION chokes and returns an
error that *looks* like a string. e.g. "Error 2036"
And, indeed, I'm able to pass that back up the chain through
the function's Variant return value.
After the func has been called, and I look at the returned value
in the Immediate window, it still looks like a
string: "Error 2036".
The fun comes when I try to do a Debug.Print.
Just printing the variable containing the error works.
viz:
-----------------------------
debug.Print curDuration_Excel
Error 2036
-----------------------------
But when I try to concatenate a string in front of the
variable, it throws an error;
viz:
-------------------------------------------------------
debug.Print "xxx" & curDuration_Excel
(throws Runtime Error 13: Type Mismatch)
-------------------------------------------------------
Same thing if I do a:
?"XX" & curDuration_Excel
Seems like my use of a variant is covering for me most of the
time, but somehow I'm getting caught when I try to concat it with
a string.
Can anybody explain what's going on here?