Referring to other classes in the same DLL

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.

Who is Participating?
percosolatorConnect With a Mentor Commented:
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


trimtromAuthor Commented:
OK Thanks very much.  A very clear and concise answer.
you are welcome.
I occasionally have brief moments of lucidity. <g>

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.