how to pass value from function to form ???

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello..

I have an event (it is for a bar code reader) that can be invoked no matter which of my forms is active. In one case, I want to take the barcode data and place it in a text control on a form that has already been loaded. I cannot figure out a way to accomplish this....

If anyone knows or has some suggestions or links, please let me kno

Thank
- d
 
Create a class with a static property (or module in vb.net) and when the
event is fired, set the static property with the value you want. Then
whatever form you are in or is up can reference it. If you know what form
is up you can always create a property in the form and use the event to set
it but that's not the case here so I think the static class will do it for
youl.
dw said:
Hello...

I have an event (it is for a bar code reader) that can be invoked no
matter which of my forms is active. In one case, I want to take the
barcode data and place it in a text control on a form that has already been
loaded. I cannot figure out a way to accomplish this.....
 
Thanks for the suggestion. I am sort of doing that now....whenever the barcode reader event fires and scans a barcode, I store that in my class property. However, I also need to cause someting to happen on my form too. That is the part I am struggling with....trying to figure out a way to update a control on a form right after the event (in the class module) fires. I just don't see how this can be accomplished.
 
This should do it for you. when the event fires you can set the value of
the shared property and you your form is live so you can provide an access
modifier to it so you cna update the control. Anytime that you set a
property you can raise an event. So when that shared property changes you
can raise your own event. Anyway, you can have a handler for this in
multiple places, just point to the handler in the static class (you don't
even have to make it static if you are going to reference it from a form
that's in scope.)

Where is the event handler now?

If you show me the code I can get you through it but if I had the code, it'd
be easier for me to write it for you with comments than explain here...I'll
be up for a while tonight.

HTH,

Bill



but"dw said:
Thanks for the suggestion. I am sort of doing that now....whenever the
barcode reader event fires and scans a barcode, I store that in my class
property. However, I also need to cause someting to happen on my form too.
That is the part I am struggling with....trying to figure out a way to
update a control on a form right after the event (in the class module)
fires. I just don't see how this can be accomplished.
 
Bill..

Thanks for the help and offer

Intially, someone placed the event handler for the barcode reader in the main form. My plan is to move it from the main form to a separate module(vb.net). I am hoping that by moving it to a module, it can be visible (and also "see") the other forms and it will make it easier/possible for me to do what I need

I am unfamiliar with the term "access modifier". Are you saying (writing) that by just setting a new value in my barcode reader event, I can raise an event on a form? That would be great.

My main problem now is trying to figure out if a form is active/open or not....and how to replace values in it and refresh it

Right now the code is like this

Private Sub bcr_BarcodeRead(ByVal sender As Object, ByVal bre As Intermec.DataCollection.BarcodeReadEventArgs) Handles bcr.BarcodeRea
' set a variable to the incoming barcode valu
Dim strBarcodeID As String = bre.strDataBuffer.Trim
' call the function that will lookup via the new barcode valu
Dim ProductExist As Boolean = objProduct.ProductIDExist(strBarcodeID
' if the product exists, I want to either launch a small detail form
' if it isn't already opened...otherwise I want to replace the values in th
' form controls if that form is already/currently open

' if the product doesn't exist yet, I want to open the product details as a new entry and
' place the barcode value in one of the controls
If ProductExist The
' here I just get the product details from the sqlCE database and set some object properties to the
' values in the database...and start the form
Else
' if the product doesn't exist and the user is on the product details form...I would like to update the control on the for
End I

End Sub
 

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

Back
Top