Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

929 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

11 Experts available now in Live!

Get 1:1 Help Now