Solved

Sub-Sectioning a DLL file

Posted on 2004-04-17
8
152 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
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…

730 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