Results 1 to 3 of 3

Thread: Invoking Methods at Runtime?

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2002
    Location
    Ireland
    Posts
    2

    Question Invoking Methods at Runtime?

    Hi,

    I need to be able to create and call a method of a COM component dynamically at runtime.

    E.g...

    If a user enters the string "Cpn1" as the name of a component, "Cls1" as the name of a class within that component and "Mth1" as a method of that class, how can I create and invoke the method at runtime.

    If I knew the requirements at design time I could write the following...

    Dim objCls1 as Cpn1.Cls1

    set objCls1 = New Cpn1.Cls1
    objCls1.Mth1

    set objCls1 = Nothing

    At runtime however, while I can declare the object "As Object" and create it using 'CreateObject("Cpn1.Cls1")', I haven't a clue as to how to invoke the "Mth1" method.

    Can it be done?
    Cynapse

  2. #2
    pvb
    Guest
    Use CallByName, attached is a sample. Open the Group1.vbg file and run.
    Attached Files Attached Files

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2002
    Location
    Ireland
    Posts
    2
    Thanks very much!

    I guess I should have done a better search of MSDN.
    Cynapse

Posting Permissions

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



Click Here to Expand Forum to Full Width