Results 1 to 3 of 3

Thread: Module as object

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Posts
    71
    How would I reference a module as an object. I have a line of code that uses the CallbyName function. I want to say CallbyName(myModule, myProc, vbmethod, (myarguments)) Any ideas on declaring this module as an object and setting it so that I can use it?

  2. #2
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    Create a Class Module (MyClass) with a method (function) "myproc", and then instance it thus:

    Dim oClass As myClass
    Set oClass = New myClass

    returnvalue = CallByName(oClass, "myproc", vbMethod, args...)

    The arguments must obviously be in line with the function declaration.

    Cheers,

    Paul.

    P.S. CallByName uses Late Binding and is pretty slow, you could just use

    returnvalue = oClass.myproc(args)

    P.
    Not nearly so tired now...

    Haven't been around much so be gentle...

  3. #3
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    Having just seen your previous thread, the reason CallByName works in a form is that a form IS an object. CallByName only works with objects which is why you need to use a class module to create an object whose methods you reference.

    Hope that is clear,

    Paul.
    Not nearly so tired now...

    Haven't been around much so be gentle...

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