Solved

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

Posted on 2003-10-22
4
232 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
ClickOnce Install - Shortcut Question 3 58
count7 challenge 12 70
countX 22 70
Birthdays 3 14
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

762 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now