VB Equivalent for Eval() {Access Basic} or Indirect() {Excel} functions 
Author Message
 VB Equivalent for Eval() {Access Basic} or Indirect() {Excel} functions

I am trying to find a way to pass execute a function or sub without knowing
at the time of execution what the name is.  In many cases I develop
applications which are table driven and allow the user to specify the
functions.  In Access Basic you can use   vnt = Eval(sTestFunction) and in
Excel, Indirect(sTestFunction).  There must be a way in VB.  I would
appreciate any help.  Thanks

Here's a sample:

Sub Main()
    Dim sTestFunction as string
    sTestFunction = "Test1()"
    RunFunction sTestFunction
End sub

Sub RunFunction(sFunctionName as string)
    'Execute the public function which is defined by sFunctionName
    ??????????????????
End Sub

Function Test1() as boolean
    Msgbox "Test1 Function"
End Function



Thu, 17 Aug 2000 03:00:00 GMT  
 VB Equivalent for Eval() {Access Basic} or Indirect() {Excel} functions

Hi Rosemary:

VB does not support Eval (hopefully in future versions it will).  AFIK, the
only way to do this is to hardcode the selection:

Sub RunFunction(sFunctionName as string)
    'Execute the public function which is defined by sFunctionName

    Select Case sFunctionName
    Case "Test1", "Test1()"   'You could use one or the other, or both
        Test1
    Case "Test2", ...etc
         Test2
    ...etc
    End Select
End Sub

Hope this helps,

Doug.



Fri, 18 Aug 2000 03:00:00 GMT  
 VB Equivalent for Eval() {Access Basic} or Indirect() {Excel} functions

VB don't have anything that can help you, almos yet.
But, I'm implementing Sax Basic Engine (www.saxsoft.com) and it may help
you.
It's a clone of VBA and have a lot of methods and properties that allow you
to execute macros that you can store in external modules.
I recomend it!

Enjoy this help!



Quote:
> I am trying to find a way to pass execute a function or sub without
knowing
> at the time of execution what the name is.  In many cases I develop
> applications which are table driven and allow the user to specify the
> functions.  In Access Basic you can use   vnt = Eval(sTestFunction) and
in
> Excel, Indirect(sTestFunction).  There must be a way in VB.  I would
> appreciate any help.  Thanks

> Here's a sample:

> Sub Main()
>     Dim sTestFunction as string
>     sTestFunction = "Test1()"
>     RunFunction sTestFunction
> End sub

> Sub RunFunction(sFunctionName as string)
>     'Execute the public function which is defined by sFunctionName
>     ??????????????????
> End Sub

> Function Test1() as boolean
>     Msgbox "Test1 Function"
> End Function



Sat, 19 Aug 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. VB Equivalent for Eval() {Access Basic} or Indirect() {Excel} functions

2. VB6 Equivalent of VBA Eval() function ?

3. What is equivalent to Eval() function?

4. Function equivalent to VBScript's Eval

5. Problem with VB for Access 97 using Eval function

6. Use of Excel functions in visual basic functions in excel module

7. Equivalent to the javascript Eval() in VB?

8. VB equivalent of VBA eval()?

9. Eval equivalent in VB?

10. eval equivalent in VB

11. Visual Basic Eval() Function?

12. Visual Basic Eval() Function?

 

 
Powered by phpBB® Forum Software