Results 1 to 2 of 2

Thread: [RESOLVED] Passing data from form to form with threading

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    144

    Resolved [RESOLVED] Passing data from form to form with threading

    Hi,

    I'm having a bit of an issue to get some data from a form to another.

    First form is the main one, named Mode.vb
    The second form is named ValueTest.vb and is a small "pop-up" form inviting the user to change a value.

    On the 2nd form there are two textboxes, one is ReadOnly and should display a threshold value taken from the 1st form. The second textbox is for the user to enter a value.
    The method giving the value in the first textbox is running on another thread than the UI because it's heavy image processing.

    I'd like to send the threshold value calculated in the processing thread to the ValueTest form in order to display the current threshold value that has been calculated.
    Then show the valueTest form as a pop-up on top of an image (this is done but maybe it's not done the right way as it's being shown from a method that is running on the processing thread).

    The user can then choose to change this value by entering a new value in the second textbox. The new value is used as a new threshold in the image processing. That is presently working.

    Here is how I started:

    vbnet Code:
    1. '
    2. Private Sub ValueTest_Shown(ByVal sender As object, byVal e As System.EventArgs) handles Me.Shown
    3.  
    4. Dim threshold2display As integer = Mode.CalculatedThreshold
    5.  
    6. End sub

    with CalculatedThreshold defined on the main form as :

    vbnet Code:
    1. '
    2.  Public CalculatedThreshold As Integer

    Then I'm trying to display the threshold2Display in the ReadOnly textbox.

    I can't figure out why my first textbox always display "0" as my threshold is clearly not 0. I'm testing the value by displaying it on the UI in another textbox before importing it to the ValueTest form, and it is the correct value. I need it to be displayed on the pop-up form and not on the UI to be clearly visible on top of a displayed image, whereas the UI should remain in the background at this moment.

    Hope I was clear enough with my issue,

    Thank you for any input !

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    144

    Re: Passing data from form to form with threading

    Ok my head was really in the wrong place... I used the name of the form instead of the name of the variable:

    vbnet Code:
    1. '
    2.  
    3. Dim ObjNewForm As New ValueTest

    And then


    vbnet Code:
    1. '
    2.  
    3. ObjNewForm.threshold2display = Me.CalculatedThreshold
    4. ObjNewForm.ShowDialog()

    And display in the Shown of the ValueTest form.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width