2012-05-02 74 views
1

我有一个看起来像这样的子程序。它有两个参数。无法传递多个参数

Sub Advance(ByRef listR() As String, rCount) 
    ...code 
End Sub 

当我尝试调用此:

Advance listR:=theList, theCount 

它给了我一个编译错误:

Expected: named parameter

这是为什么?它工作正常,就像...

Sub Advance(rCount) 
    ...code 
End Sub 

,并通过调用:

Advance theCount 

或者也可与正好阵列参数。

回答

3

我相信你可以叫你的子以下任何方式,但你不能名字的第一个参数,而不是命名第二个:

Advance listR:=theList, rCount:=theCount 
Advance rCount:=theCount, listR:=theList 
Advance theList, rCount:=theCount 
Advance theList, theCount 

Call Advance(listR:=theList, rCount:=theCount) 
Call Advance(rCount:=theCount, listR:=theList) 
Call Advance(theList, rCount:=theCount) 
Call Advance(theList, theCount) 
2

MSDN

When you supply arguments by a mixture of position and name, the positional arguments must all come first. Once you supply an argument by name, the remaining arguments must all be by name.

+0

+1我正在寻找它,但无法找到它。 – assylias