|
-
May 5th, 2002, 07:21 PM
#1
Thread Starter
New Member
Importing DLL classes to VB
Hi, I hope someone knows how to do this because I can't seem to figure it out. I've written a DLL in C++ which contains a class I want to use in VB. Importing functions from a DLL is easy.. but I can't figure out how to import a class.
I am exporting my class from my DLL as such:
class __declspec(dllexport) TestClass {
public:
int x;
};
Notice the "__declspec(dllexport)" flag so i am NOT working with any DEF files or anything like that. How may I instantiate a TestClass object in my VB app?
Thanks in advance.
-
May 5th, 2002, 07:25 PM
#2
When it comes to classes VB can only handle classes in COM objects.
What you have to do is set a reference to the dll and instanciate an object in the normal way.
VB Code:
Private obj As ClassName
Private Sub Form_Load()
Set obj = New ClassName
End Sub
Best regards
-
May 5th, 2002, 07:37 PM
#3
Thread Starter
New Member
thanks. ok.. so i should reference it in my com object and instantiate the class in my vb prog like you've shown me. Got it, but how can i reference the class in my C++ DLL from my COM object? Do you know what the line of code would look like?
Thank you very much for your kind help.
-
May 5th, 2002, 07:41 PM
#4
Sorry I wasn't very clear. VB can only use classes if the classes themself has a COM interface.
You can't use export classes in VB.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|