Executing a Method dynamically

Results 1 to 2 of 2

Thread: Executing a Method dynamically

  1. #1
    Join Date
    Dec 1969

    Default Executing a Method dynamically

    Hi All,<BR><BR> Is it possible to create and execute some part of code at runtime in VB. VBScript has a method called &#039;Execute&#039; which can be used for this purpose.<BR><BR>My requirement is I will get the class name(String) and the method name (String) as inputs to my method. This method has to be executed at runtime.<BR><BR>Thanks,<BR>Madhukar Hebbar M

  2. #2
    Join Date
    Dec 1969

    Default You answered your own question

    &#060;%<BR>Sub dynamicMethodCall( className, methodName )<BR> &#039; first create an instance of that class:<BR> Execute "Set tempObj = New " & className<BR> &#039; then execute the method on that instance:<BR> Execute "tempObj." & methodName & "( )"<BR>End Sub<BR>%&#062;<BR><BR>But...<BR><BR>This is a pretty bad thing to do, from a performance standpoint...so I hope you have a heluva good reason for doing it.<BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts