I have this algorithm that I want to implement on VB6.
Sub Main() dim stringVal1 as string, stringVal2 as string dim getOne as boolean stringVal1 = "FunctOne" stringVal2 = "FunctTwo" if getOne then 'Call Function with function name assigned to stringVal1 ... how to call the function here?** else 'Call Function with function name assigned to stringVal1 ... how to call the function here?** end if End Sub Function FunctOne() Msgbox "I'm function one" End Function Function FunctTwo() Msgbox "I'm function two" End Function
Can this be done in VB6?
Generally, such code patterns point to errors in your software design.
In the rare cases where this is really needed, CallByName accomplishes this.
CallByName
Example:
Call CallByName(Me, "NameOfFunction", vbMethod, arguments)
1.4m articles
1.4m replys
5 comments
57.0k users