编译erfc函数的错误

时间:2017-05-14 20:49:30

标签: excel-vba vba excel

我尝试使用erfc,但它说参数不是可选的。

下面给出一个例子

For j = 0 To 150 
    f = 1
    For m = 1 To j
        f = f * m
    Next
    Application.WorksheetFunction.Erf = (Application.WorksheetFunction.Erf) + (-1) ^ j * b ^ (2 * j + 1) / ((2 * j + 1) * f)
Next

Application.WorksheetFunction.ErfC = 1 - 2 / Sqr(3.14) * Application.WorksheetFunction.Erf

MsgBox (Application.WorksheetFunction.ErfC)

xf1 = (wa + 2 * sp) * q / (4 * cl ^ 2 * 3.14 * hf)
xf2 = Exp(b ^ 2) * Application.WorksheetFunction.ErfC

xf3 = 2 * b / Sqr(3.14) - 1

xf = xf1 * (xf2 + xf3)

1 个答案:

答案 0 :(得分:0)

根据MSDN documentation,至少需要将一个参数传递给Erf方法:

Name   Required/Optional  Data Type  Description  
Arg1   Required           Variant    Lower_limit - the lower bound for integrating ERF.  
Arg2   Optional           Variant    Upper_limit - the upper bound for integrating ERF.
                                     If omitted, ERF integrates between zero and
                                     lower_limit.

因此,使用零参数(例如Application.WorksheetFunction.Erf)调用它会给你一个"参数不是可选的"错误。

您也无法将Erf设置为一个值,即

Application.WorksheetFunction.Erf = ...

无效。