Solved

Sub-Sectioning a DLL file

Posted on 2004-04-17
8
148 Views
Last Modified: 2010-05-02
Hi experts!

I'm writing an ActiveX dll from VB which has got a LOAD of different functions.  What i'd ideally like to do, for the sake of easy scripting is to subdivide to dll.

EG  rather that going:

MyDll.GetRecordset

MyDLL.RandomNumber

to have

MyDLL.DatabaseFunctions.GetRecordset

MyDLL.NumericFunctions.RandomNumber

If not i'll just have to write 2 DLL files or tolerate it as it is.

Thanks for you help and time.

Bobeo
0
Comment
Question by:Bobeo
  • 4
  • 2
8 Comments
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 10849087
A single DLL can hold MULTIPLE classes, and each class can provide its own set of methods and properties.

So your DLL would have the classes

Public Class DatabaseFunctions
   Public Function GetTRecordSet() as Recordset
     ' add you code here
   End Function

End Class

Public Class NumericFunctions
   Public Function RandomNumber() as Single
     'add your code here
   End Function
   
   Public Function RandomNumber(Seed as Integer) as Integer
     ' add your code for this version of the function
   End Function

   Public Function RandomNumber(LowValue as Integer, HighValue as Integer) as Integer  
     'add code for the function to return a value between LowValue and HighValue  
   End Function
End Class


then you access these functions, in their separate classes within your DLL, exactly as you have described in your question.

AW
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 10849092
the above was in .NET, in VB 6, you cannot have two functions with the same name, so your code would look like this:


Public Class DatabaseFunctions
   Public Function GetTRecordSet() as Recordset
     ' add you code here
   End Function

End Class

Public Class NumericFunctions
   Public Function RandomNumber() as Single
     'add your code here
   End Function
   
End Class
0
 
LVL 3

Author Comment

by:Bobeo
ID: 10849104
Hi Arthur_Wood!  And thanks for your reply!

but when i put

Public Class DatabaseFunctions

into my Class module it give me the error

Compile Error
Expected: End of statement

Am I doing something wrong?!
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 3

Author Comment

by:Bobeo
ID: 10849117
It's picking up the word 'Class' as a variable, not a function.

As in

Public Class as Integer

Etc!
0
 
LVL 3

Author Comment

by:Bobeo
ID: 10849261
Upping the points to 500
0
 
LVL 3

Author Comment

by:Bobeo
ID: 10849622
OK, problem solved.

I used the VB Class Builder Add-In to drag all of my classes into one class, the compiled the DLL from that.

Will get Community Support to close the question
0
 
LVL 1

Accepted Solution

by:
GhostMod earned 0 total points
ID: 10881776
PAQd, 500 points refunded.

GhostMod
Community Support Moderator
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

743 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

15 Experts available now in Live!

Get 1:1 Help Now