• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 137
  • Last Modified:

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?

Thanks
0
gamestors
Asked:
gamestors
  • 2
  • 2
1 Solution
 
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"
0
 
gamestorsAuthor Commented:
Can you give me an example?

Thanks
0
 
manojaminCommented:
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
    A.FromAToD
End Sub

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

Hope this will help you...

0
 
manojaminCommented:
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.

0
 
gamestorsAuthor Commented:
Thanks
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now