Solved

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

Posted on 2013-01-09
5
914 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

803 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