Call procedure via variable

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can I call a procedure that's stored in a variable?

I recall someone once advising me to use an Eval but it's not working, nor
does "Call x" where 'x' contains my procedure name (ok, that was a longshot).

Function or sub, can't figure it out. Seems so simple (and I'm sure it will
be).
 
You could use CallByName or Application.Run depending on what it is you're
trying to do exactly. Eval is good for evaluating an expression, so, it
could execute function i.e., Eval("IsNull('whatever')"), but you're limited
in respect to what parameter types can be passed (everything gets coerced as
a string)...so, this wouldn't work: Eval("IsNull(" & Null & ")"). But
Application.Run or CallByName allow variant parameters.
 
Paul,

You state that "everything gets coerced as a string". I am not sure that is
correct. I have a function that accepts a boolean argument and returns a
string. It works fine with the eval function. Subs cannot be called with an
Eval. I also built an applicatoin where business rules were subject to
frequent changes, so we built some of our rules into a table, and used the
table fields with Eval to execute our rules.

On a philosophical note, I would not design a system where calls are based
 
My mistake...you're right, it will coerce a boolean string correctly, i.e.,
Eval("True"). But the point I was really trying to make was that you have
to be careful because it doesn't always coerce correctly....hence the
example.
 
Back
Top