Solved

Accessing a class from DLL

Posted on 2006-06-17
8
546 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
  • 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 400 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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 9

Assisted Solution

by:Naveen Swamy
Naveen Swamy earned 100 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 run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now