tomnich
asked on
Run a function/sub based on the value of a string
I want to create a string which is the name of a sub/function in code and run that code, eg
sFunction = "MyFunc"
AMethodofRunning sFunction
where AMethodofRunning is a function which calls the subroutine sFunction. The question is, what is AMethodofRunning ? (In MS Access you use Application.run sFunction)
sFunction = "MyFunc"
AMethodofRunning sFunction
where AMethodofRunning is a function which calls the subroutine sFunction. The question is, what is AMethodofRunning ? (In MS Access you use Application.run sFunction)
Not. But you can do the following:
select case MyString
case "MyFunc"
MyFunc arg
case "MyFunc1"
MyFunc1 arg
case "MyFunc2"
MyFunc2 arg
end select
select case MyString
case "MyFunc"
MyFunc arg
case "MyFunc1"
MyFunc1 arg
case "MyFunc2"
MyFunc2 arg
end select
mirkwood: thanks for you reply...
Impossible!!!!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
He, chabaud, we probably answered together. Only one minute in between
He, funny. Two accounts for one person. Oh Linda.....
In VB6, there is a new language feature named CallByName.
You might be able to trick it into doing what you want...
You might be able to trick it into doing what you want...
Sorry about that...
I must have answered somewhere in the middle there...
Glad you got your answer!
I must have answered somewhere in the middle there...
Glad you got your answer!
to mirkwood: Impossible is not VB !!!!
We have to read the vb6 doc more deeply...
We have to read the vb6 doc more deeply...
Or use select:
Select case sFunction
case "MyFunc1"
MyFunc1
case "MyFunc2"
MyFunc2
end select