How to call a sub defined in DLL module not belong to any class 
Author Message
 How to call a sub defined in DLL module not belong to any class

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.


Mon, 28 Jun 2004 23:47:25 GMT  
 How to call a sub defined in DLL module not belong to any class
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

Quote:
> 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.



Tue, 29 Jun 2004 01:13:58 GMT  
 How to call a sub defined in DLL module not belong to any class
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
Quote:
>-----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
Quote:
>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.

>.



Tue, 29 Jun 2004 01:49:09 GMT  
 How to call a sub defined in DLL module not belong to any class
Within your project, instead of Object.FunctionName, use FunctionName..
There's no way (other that creating a wrapper in a class) to call a function
in a bas module from an external dll/ocx/whatever

--
Ken Halter
MS-MVP-VB
Please respond only to the newsgroups so all can benefit.


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.

> >.



Tue, 29 Jun 2004 04:46:01 GMT  
 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.

> >.



Wed, 30 Jun 2004 04:34:19 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. How to call one VB class module method from another class in an ActiveX dll

2. popupmenu command yields sub or fn not defined from module

3. Sub or function not defined - DLL problem

4. Bad Calling Convention error 49 - due to calling a Sub in a .bas module

5. User Defined Datatypes and Class Modules

6. Error using user-defined type in parameter of public procedure in a class module

7. Sub Property in Class module

8. Class Module / User Defined Type

9. User Defined types into a class module

10. Compiler Error Question, attempting to make a class module see a user defined type

11. User Defined Datatypes and Class Modules

12. Passing an array of user-defined data type to a class module

 

 
Powered by phpBB® Forum Software