_Calling a function with variable name...

Discussion in 'AutoCAD' started by smd, Dec 9, 2004.

  1. smd

    smd Guest

    From within a function, I want to call another function which name is an (String)argument of the function in which I am...
    e.g. Call BATCH(ToDoFunction as String)... ToDoFunction is the name of a function wich is to be triggererd somewhere in the BATCH function... is this possible ? ... Thanks ... Zenomy
     
    smd, Dec 9, 2004
    #1
  2. smd

    fantum Guest

    If your version of VBA is recent enough you can use CallByName:

    In Class1:

    Public Sub TestSub()
    MsgBox "Hello, World!"
    End Sub


    In your BATCH function:

    Public Function BATCH(ToDoFunction as String)
    Dim C as Class1
    Set C = New Class1

    CallByName C, ToDoFunction, VbMethod

    Set C = Nothing
    End Function

    In your calling code:

    ...
    Call Batch("TestSub")
    ...
     
    fantum, Dec 10, 2004
    #2
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.