Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get the return value of a function executed via eval 1

Status
Not open for further replies.

FancyPrairie

Programmer
Oct 16, 2001
2,917
US
I call a function (element_myfunction) via Eval. I want the function to return a value. How do I do it? This is what my code looks like.
Code:
    Dim myReturnValue
    Dim strElementID

    strElementID = "Element1"
    myReturnValue = Eval(strElementID & "_myFunction")
    if (myReturnValue = "abc") then ...

Function Element1_myFunction()
    Element1_myFunction = "abc"
End Function
 
The following seems OK to me:
Code:
    Dim myReturnValue
    Dim strElementID
    strElementID = "Element1"
    myReturnValue = Eval(strElementID & "_myFunction")
    if (myReturnValue = "abc") then msgbox "OK"
Function Element1_myFunction()
    Element1_myFunction = "abc"
End Function

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks for verifying this. It made me examine my code again. I discovered that I had forgot to declare myReturnValue in my original code (had Option Explicit set but visual studio didn't report it to me).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top