_Calling a function with variable name...
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
_Calling a function with variable name...

 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA
Author Message
smd
Guest





Posted: Thu Dec 09, 2004 5:33 pm    Post subject: _Calling a function with variable name... Reply with quote

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

Back to top
fantum
Guest





Posted: Fri Dec 10, 2004 5:21 pm    Post subject: Re: _Calling a function with variable name... Reply with quote

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")
...
Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Powered by phpBB