accessing data from a class event in a form

G

Guest

I have a multiproject solution; one of the projects is a group of classes
doing data massage and insertions. One of the other projects is a UI that
kicks off the process in certain situations. I'd my UI to be able to read
properties or events or whatever it takes so the UI can display messages
about what's happening in the data project. However I can't find any
documentation on how to do this. Can someone please point me in the right
direction? TIA.
 
G

Guest

It depends on where you instantiate instances of your classes. If it's in
the UI, then you can put events in your classes and handle them in your UI
thread. There are many ways to do this.
 
G

Guest

I thought it might be something along these lines. Sounds like your saying I
need event handlers in the UI code to capture the output of class events. Can
you point me at some good examples? TIA.
 
G

Guest

Never mind I figured it out. For the benefit of others here is my code.

In the declarations area of one of my classes I inserted the following:
Public Event UIData(ByVal text As String)

In one of the class functions do some processing and want to send a message
to the UI so inserted the following:
RaiseEvent UIData("Successful File Read. Record count of " & CStr(rcount) &
". Database Insert commencing....")

Next, in the load event of the form I did the following:
AddHandler processor.UIData, AddressOf DataHandler - to watch for the output
of a raised event in my class.

Finally I added a sub() to insert the data to a list box:
Public Sub DataHandler(ByVal data As String)
lstEvents.Items.Add(data)
End Sub
 
G

Guest

That's it! You can also setup to access procedures and properties of the
form class in the classes setting a property in the Class to the Form or pass
the Form as a variable in the New procedure of the Class. Then in the Class,
you can call procedures/properties in the Form class.

Anyway, sounds like you are off and running until the next problem arises.
Good Luck.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top