问题
assumed I have a DLL that exports functions with variable arguments list like this:
int myfunc(int arg1,...)
Here "..." is a undefined number of additional arguments. Can such functions be called out of a Visual Basic application or is VB locked to functions with fixed arguments?
I'm just asking to avoid a design problem that would lock-out VB programmers...
Thanks!
回答1:
In VBA, functions can hand over an undefined number of arguments, so there should be no problem.
Directly in VBA, you'd define a function like this:
Function SumAll(ParamArray var() As Variant) As Double Dim i As Integer Dim tmp As Double For i = LBound(var) To UBound(var) If IsNumeric(var(i)) Then tmp = tmp + var(i) Next SumAll = tmp End Function
来源:https://stackoverflow.com/questions/14716385/variable-argument-list-with-visual-basic