
How to call a sub defined in DLL module not belong to any class
In your .bas file you have a public sub called foo(parameter1, param2). In
your .cls file Class1 you make a function
foo1(param1, param2)
foo param1, param2
End Sub
To call the function in the dll from your exe,
Dim c1 As Class1
Set c1 = new Class1
c1.foo1 x1, x2
It may be possible to name both subroutines "foo", but I avoid this for the
confusion that may result.
Jim Deutch
MS Dev MVP
Quote:
> You are right, it is in the .bas file, not .cls file.
> sorry for inconvenience.
> How can I delegate the function to a bas module?
> Thanks.
> Yongwei
> >-----Original Message-----
> >You confuse me.
> >If the sub is in a .cls file, it IS in a class module.
> Perhaps you mean a
> >..bas file? A program referencing your dll can only call
> Public properties
> >and methods of Public classes. You can delegate the
> actual computations to
> >functions in .bas modules, though.
> >You cannot go the "public declare" route with a VB dll.
> >Jim Deutch
> >MS Dev MVP
> >> I have a sub defined in a VB dll project, in a .cls
> file,
> >> since it is not belonged to any class module, I can not
> >> use Object.FunctionName to call it, is there any easy
> way
> >> to call it, rather than put "public declare " to import
> it
> >> from a foreign dll. how can I do it? I had reference
> this
> >> dll in my project.
> >> Thanks.
> >.