Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Sub-Sectioning a DLL file

Posted on 2004-04-17
8
Medium Priority
?
157 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
Industry Leaders: 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

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.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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

972 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