Solved

how to pass data between forms using delegates with vb.net

Posted on 2013-01-09
5
906 Views
Last Modified: 2013-01-09
I would like to know if how to read data from other form when Using a thread

this is my code:
        trd = New Thread(AddressOf analisis)
        trd.IsBackground = True
        trd.Start()

Open in new window


sub analisis()
        Dim test As Double
        test  = cdbl(secondform.example.text)
end sub

Open in new window


Give me this error I use the thread when test try to read the value from the textbox "example"
error
but I if remove the thread test obtain without problems the value from example

What I need to do to read the value of the the textbox example using the thread????
0
Comment
Question by:altariamx2003
  • 2
  • 2
5 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 38761195
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 38761307
You can READ a controls value from another thread no problem.  I believe your error is because the value in the TextBox cannot be converted to a Double.  It is either blank or something that is not a number representing a Double.  Use Double.TryParse() instead...
0
 

Author Comment

by:altariamx2003
ID: 38761479
thanks for answer Idle, but that was is not the problem

when I tried to assign the value of the textbox example inside the thread show me the error that I post

but outside the thread everything works great

I use the solution of Codecruiser


thanks anyway
0
 

Author Closing Comment

by:altariamx2003
ID: 38761481
this is the solution

thanks!!!
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 38761657
The error you posted was indeed associated with the conversion of a string to a double, and had nothing to do with threading.  =)

The code you posted was reading from the control, which does not create an error.

Writing to the control from the thread, which you did not have in your posted code, would create a different exception that can be solved with Invoke() and Delegates.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 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

8 Experts available now in Live!

Get 1:1 Help Now