?
Solved

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

Posted on 2013-01-09
5
Medium Priority
?
941 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 2000 total points
ID: 38761195
0
 
LVL 86

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 86

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

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