Accessing the client from the DLL

How can I access the methods and properties of a form that calls a dll from a dll?

LEt's say,  I have form "A"  and DLL  "D"

From A, I call a method in D.  How can the method in D access the properties and controls in A?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
You could have a Private property in the DLL that contains a Form reference.  

You could then pass in the Form reference for "A"
gamestorsAuthor Commented:
Can you give me an example?

Do following,

1) Create New Active X dll in VB and put this code in you Class1

Public Function DFromA(X As Object) As Long
    MsgBox X.DCallingA
End Function

2) Compile it (it should register it self as Project1)

3) Create New Active X dll in VB andput this code in your Class1 (Make sure that you change the Project Name from Project1 to Project2, otherwise it will conflict), Also put the reference to Project1 that you have just compiled.

Private D As New Project1.Class1
Public Function DCallingA() As Long
    DCallingA = 10
End Function
Public Function FromAToD() As Long
    Call D.DFromA(Me)
    FromAToD = 15
End Function

4) Compile it (it should register it self as Project2)

5) Craete C as new Standard Exe and put the reference to Project1. Also put a command button on the from and following code.

Private Sub Command1_Click()
    Dim A As New Project2.Class1
End Sub

6) Compile it and run it, you should get MsgBox with the text 10

Hope this will help you...


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Make this as (Project2 not Project1, it's a typo)

5) Craete C as new Standard Exe and put the reference to Project2. Also put a command button on the from and following code.

gamestorsAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.