Call a Variable Procedure Name

T

Turner

I would like to be able to use a Variable as a procedure
name. I tried the example below to no avail. Is there a
way to accomplish:

Const stMyMsg As String = "myMsg"

Call stMyMsg

I have a procedure called myMsg.

Thanks!
 
A

Albert D. Kallal

You have to use a function name.


Public Function stMyMsg

msgbox "hello..this is stMyMsg"

end function


Then you can go in code:

dim strWhatFunc as string

strWhatFunc = "stMyMsg"

eval(stWhatFunc)

So, using eval, you can call a function. It don't work for subs..but useally
this is not a problem....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top