Referring to other classes in the same DLL

Posted on 1998-08-05
Medium Priority
Last Modified: 2010-05-03
I am a VB student with the following problem:

I have a standard project with a standard startup module (StartModule).
I have a DLL(DLLA) with two classes (ClassA and ClassB).

StartModule has instantiated examples of both ClassA and ClassB.  I want ClassA to be able to
call ClassB via the instance of ClassB started by StartModule.

I have got this far:

public ExampleA as new ClassA

set exampleA.objparent = me

DLLA:ClassA (and ClassB)
public objparent as ?????????? what

I can't say "public objparent as StartModule" because VB wont recognise that.  StartModule is not a class and it is in a separate project.

(I was thinking of referring to ClassB from ClassA as "Startmodule.ClassB")

In essence I am trying to get one class in a DLL to call another class in the same DLL.  But as they are separate instances I am not sure how to do it.

I would be most grateful for a solution with code examples.

Question by:trimtrom
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

Accepted Solution

percosolator earned 400 total points
ID: 1468032
ok.  here is sample code to show you how to pass instances about.


Option Explicit

'Start Module
Public ExampleA As New ClassA
Public ExampleB As New ClassB

Public Sub main()

    'Set ExampleA's ClassB object to the Start Module's Instance
    Set ExampleA.MyClassB = ExampleB
    'set example B's Message property
    ExampleB.Message = "This Message is Available to Both Sub Main," & _
                        "And the Instance of ClassA"

    'display ExampleB's Message
    'show that ExampleA is using the same instance of ExampleB
    'by displaying ExampleA's instance of ClassB's message

End Sub


'Class A

Option Explicit

Dim objClassB As ClassB

Public Property Set MyClassB(C As ClassB)
    Set objClassB = C
End Property

Public Sub ShowClassBMessage()

End Sub



Option Explicit

Dim strMessage As String
Public Property Let Message(S As String)

    strMessage = S
End Property
Public Sub PrintMessage()

        MsgBox strMessage
End Sub



Author Comment

ID: 1468033
OK Thanks very much.  A very clear and concise answer.

Expert Comment

ID: 1468034
you are welcome.

Expert Comment

ID: 1468035
I occasionally have brief moments of lucidity. <g>


Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Suggested Courses
Course of the Month14 days, 9 hours left to enroll

770 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