0

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)

2 Answers 2

3

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)
0
Function Add(int1, int2)
    Add = int1 + int2
End Function

intSum = Eval("Add(1, 2)")
' or...
intSum = Eval("Add(" & intParam1 & ", " & intParam2 & ")")

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.