Reputation: 6612
I want to call a function with a dynamic name, which can be done with Eval
:
fName = "TestFunction"
Call Eval(fName)
This works great, but how do I pass parameters to this function call? Something like this doesn't work:
Call Eval(fName)(Param1, Param2)
Upvotes: 0
Views: 569
Reputation: 70923
If you use Eval
you need to prepare the code to execute
Call Eval(fName & "(" & Param1 & "," & Param2 & ")" )
What you are trying needs GetRef
Call GetRef(fName)(Param1, Param2)
Upvotes: 3
Reputation: 16311
Function Add(int1, int2)
Add = int1 + int2
End Function
intSum = Eval("Add(1, 2)")
' or...
intSum = Eval("Add(" & intParam1 & ", " & intParam2 & ")")
Upvotes: 0