如何在VBA中使用空数组默认值声明可选函数参数?

时间:2014-10-22 22:56:11

标签: vba ms-access optional-arguments

我正在尝试构建下面的例程。例程的最后一个参数是一个可选数组,默认情况下它应该有两个空字符串。下面的声明不起作用,它给了我这个错误:编译错误:需要常量表达

Public Sub CreateReport(rpt As Report, rptSelectFLDS As Variant, _
                        rptWhereConds As Dictionary, _
                        Optional rptTopSelect As Variant = Array("", ""))

1 个答案:

答案 0 :(得分:3)

如何查看参数IsMissing()

Public Sub CreateReport(rpt As Report, rptSelectFLDS As Variant, _
                        rptWhereConds As Dictionary, _
                        Optional rptTopSelect As Variant)

    If IsMissing(rptTopSelect) Then rptTopSelect = Array("", "")