VBA函数和数组

时间:2017-03-13 22:58:55

标签: vba

我试图在vba中编写一个调用其他函数的函数,并将输出显示为函数数组。被调用的函数已经过测试和工作,但调用其他函数的函数返回#Value!误差修改。社区可以就可能的解决方案提供任何指导吗?

Public Function OptionCall(OptionType As String, CallPutFlag As String, Value As Double, Delta As Double, Gamma As Double, _
Vega As Double, Theta As Double, Rho As Double)

    If OptionType = "KE_European" Then
        Value = KE_European(CallPutFlag, Underlying, Strike, Time, Rate, Volatility)
        Delta = Delta_KE_European(CallPutFlag, Underlying, Strike, Time, Rate, Volatility)
        Gamma = Gamma_KE_European(CallPutFlag, Underlying, Strike, Time, Rate, Volatility)
        Vega = Vega_KE_European(CallPutFlag, Underlying, Strike, Time, Rate, Volatility)
        Theta = Theta_KE_European(CallPutFlag, Underlying, Strike, Time, Rate, Volatility)
        Rho = Rho_KE_European(CallPutFlag, Underlying, Strike, Time, Rate, Volatility)
    End If

 OptionCall = Array(Value, Delta, Gamma, Vega, Theta, Rho)

End Function

1 个答案:

答案 0 :(得分:0)

除非这些是全局变量,否则问题很可能是这些作为参数传递给函数的变量未在函数中声明和设置。

{{1}}