Lagos
08-24-2011, 07:35 AM
I want to select one function out of many (3)functions, by assigning the name of the selected function <Fun2> into the string variable <FunctionName>.
I then want to call the selected function and return the value from the function to the variable <Result>. How can I do that?
The code below illustrates what I want to do, but obviously it is not working.
Public Sub Main()
Dim FunctionName As String, Result As Double
FunctionName = "Fun2" ' Selected function
Result = FunctionName ' I know this does not work...
MsgBox Result
End Sub
Public Function Fun1() As Double
Fun1 = 1
End Function
Public Function Fun2() As Double
Fun2 = 2
End Function
Public Function Fun3() As Double
Fun3 = 3
End Function
I then want to call the selected function and return the value from the function to the variable <Result>. How can I do that?
The code below illustrates what I want to do, but obviously it is not working.
Public Sub Main()
Dim FunctionName As String, Result As Double
FunctionName = "Fun2" ' Selected function
Result = FunctionName ' I know this does not work...
MsgBox Result
End Sub
Public Function Fun1() As Double
Fun1 = 1
End Function
Public Function Fun2() As Double
Fun2 = 2
End Function
Public Function Fun3() As Double
Fun3 = 3
End Function