Solved

make a DLL execute a FUNCTION in a FORM with VB.NET

Posted on 2003-10-22
4
246 Views
Last Modified: 2010-04-17
This should be an EASY one guys!

I have a form called form1 and a function called doStuff. The doStuff function takes 2 integers in and does things (like modify textboxes on the form and modify global variables etc).  In form1, I can call it simply like this: doStuff(5,8) and it works great!

I have a DLL.  I launch this dll 500 times and it goes out and "does its thing" and reports back in a minute or so when it's done.  I want it to send its gathered information to the doStuff function in Form1 before it unloads itself.

In the DLL, I'm using the code:
        Dim asdf As Form1
        asdf.doit(x, y)   '(x and y are integers)

and it's not working!  It seems to be running the function as it it were IN the DLL (there are no textboxes in the DLL!)

How do I make the DLL call a function on Form1 and have it run *ON FORM1*?  Thanks in advance!
0
Comment
Question by:KnightHacker
4 Comments
 
LVL 4

Accepted Solution

by:
Sandeepk1999 earned 125 total points
ID: 9617843
You can accomplish using raising events from your DLL object. Here is the sample code:

'This code goes into your Form
    Private WithEvents obj As New ObjDLL.clsTest()

    Private Sub obj_TestEvent(ByVal i As Short, ByVal j As Short) Handles obj.TestEvent
        TextBox1.Text = i
        TextBox2.Text = j
    End Sub


'This code goes into your DLL object
Public Class clsTest
    Public Event TestEvent(ByVal i As Int16, ByVal j As Int16)

    Public Sub TestMethod()
        Dim iTest1 As Int16 = 10
        Dim iTest2 As Int16 = 20
        RaiseEvent TestEvent(iTest1, iTest2)
    End Sub
End Class
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

This is an explanation of a simple data model to help parse a JSON feed
A short article about problems I had with the new location API and permissions in Marshmallow
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

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