并行一个可选和一个子ParamArray

时间:2015-10-19 14:28:03

标签: asp.net vb.net

我在Child Process documents 中不那么专业,现在我遇到了问题:

这是sub的声明:

Public Sub DocFill(ByVal DocName As String, ByVal Optional OK As Boolean=False, ByVal ParamArray BmValues() As String)

错误信息是:

  

错误7'BmValues'未声明。由于其保护级别,它可能无法访问。

我尝试更改顺序,但最后一个值总是丢弃此错误

是否可以将这两个参数并行地声明为soehow?

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

一个可能的解决方案是做这样的事情:

Public Sub DocFill(ByVal DocName As String, ByVal ParamArray BmValues() As Object) ' Declare BmValues as an array of Object.
    Dim OK As Boolean = False ' Declare the OK Boolean within the method.

    If BmValues.Length > 0 Then ' Check whether BmValues contains anything.
        If BmValues(0).GetType() is GetType(Boolean) Then ' Check whether BmValues' first value is a Boolean.
            OK = CBool(BmValues(0)) ' If so, set OK to the first value in BmValues.
        End If

        ...

    End If

    ...

End Sub