Variable argument list with Visual Basic? [duplicate]

六眼飞鱼酱① 提交于 2020-07-06 06:13:50

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!