Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Accessing a class from DLL

Posted on 2006-06-17
8
Medium Priority
?
574 Views
Last Modified: 2008-02-20
Hello,

I'm not an experienced VB developer, I focus mainly on C/C++ and would need assistance. I have been given some sample code that I need to integrate in a project:

Dim DMApp   As New SomeClass.Application
Dim Lib     As SomeClass.Library
Dim Prof    As SomeClass.Profile

Then, I was informed that I would need to "reference" the

* fsplugin.dll
* pcdclient.dll

DLLs. Now, how do I reference these DLLs, and how do I access the classes and tell VB that it needs to look for the SomeClass class in the DLLs?

I ran across something like this:

Dim oVBObject As Object
Dim DummyVar as Variant

Set oVBObject = CreateObject("DLLName.ClassName")

and am wondering whether I can do that, just like

Dim oVBObject As Object
Set oVBObject = CreateObject("fsplugin.SomeClass")

and then do

Dim DMApp   As New oVBObject.Application
Dim Lib     As oVBObject.Library
Dim Prof    As oVBObject.Profile

Am I completely off track? Did those guys give me enough information? I feel like I'm missing something - like how do I know which DLL I really need, and how do I declare it etc.?

Thanks for any hints!


Flo.
0
Comment
Question by:Netikus
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 29

Expert Comment

by:nffvrxqgrcfqvvc
ID: 16928327
This all depends if your DLL is an activeX DLL or a standard windows DLL?
0
 
LVL 1

Author Comment

by:Netikus
ID: 16930081
Well, I haven't been told what it is, but I am 99% sure that it's a standard windows DLL. They don't do any other ActiveX stuff - so let's say safely assume it's a standard Windows DLL.

Does that help?
0
 
LVL 9

Accepted Solution

by:
justchat_1 earned 1600 total points
ID: 16930275
I think what your looking for is:
go to the project menu and click references
then click browse and add the dlls (make sure there checked too)
then your code should work
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 9

Expert Comment

by:justchat_1
ID: 16930279
O one thing missing from your code:
for all three you need to set the variable (form load is a good spot but can be in subs or functions)

ex:
Dim DMApp   As SomeClass.Application

should have a matching:
set DMApp = new SomeClass.Application

Hope that helps...
0
 
LVL 9

Assisted Solution

by:Naveen Swamy
Naveen Swamy earned 400 total points
ID: 16931856
if its a activex control, then include it in your project from project references and do the coding as suggested by justchat_1

else
keep it in the same project directory and use create object to create the instance and use its function

0
 
LVL 29

Expert Comment

by:nffvrxqgrcfqvvc
ID: 16932876
To  make one thing clear here, If its a standard windows DLL than you should see exported functions in the DLL. If this is the case you can call these functions using (Private Declare Function ExportName lib "Libraryname.dll" (parameters, etc..). However without knowing the parameters for the function your not going to make any progress.
0
 
LVL 1

Author Comment

by:Netikus
ID: 16935088
One thing that I'm confused about is how to handle classes.

I think I know how to reference a function in a DLL, e.g.

Private Declare Function MySpecialFunction Lib "mydll.dll" (ByVal FirstParm As Long, ByVal SecondParm As Long)

but how does this help - or how do I declare this - when I am referencing objects?

Dim DMApp   As New SomeClass.Application
Dim Lib     As SomeClass.Library
Dim Prof    As SomeClass.Profile

I followed justchat's advise and when to Project -> References and added both the DLLs in there. However, when I compile my project I get the following error:

"Compile error" "User-defined type not defined"

Here is the code so far:

0:Dim DocsObject As Object
1:Set DocsObject = CreateObject("FsPlugin.DOCSObjects")
2:Dim DMApp As DocsObject.Application

The error appears in line 2. I'm currently waiting for the documentation on this software but having the DLLs (fsplugin.dll and pcdclient.dll) I feel that I should get it to work?


Thanks!
0
 
LVL 1

Author Comment

by:Netikus
ID: 16937016
I was able to add the DLLs that I was given as references and that actually did the trick. I was then able to solve the problem, turns out the sample code that I was given wasn't exactly good and I had to tweak it.

There was never any DOCSObjects object in there, it was just an "Application", "Library" and "Profile" object. Just referencing those by itself worked like a charm.

Thanks again.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question