0

I open a dialog with 2 buttons. Those buttons should set a property to a value and then close the form. My main form should then grab that property. Whenever I try to grab the value it's always blank.

My Main Form

    Using SelectNextForm As New TubeSelectTo()
    SelectNextForm.Focus()
        If TubeSelectTo.ShowDialog(currentWO, status) = Windows.Forms.DialogResult.OK Then
             MessageBox.Show(SelectNextForm.numberOfBins)
        End If

The dialog

Private numberBins As String

Public Overloads Function ShowDialog(ByVal woID As String, ByVal currStatus As ResourceStatus) As DialogResult

    Return Me.ShowDialog()

End Function

Public ReadOnly Property numberOfBins() As String
    Get
        Return numberBins
    End Get
End Property

Private Sub btn1_Click(sender As System.Object, e As System.EventArgs) Handles btn1.Click
    numberBins = "1"
    DialogResult = Windows.Forms.DialogResult.OK
End Sub

Private Sub btn2_Click(sender As System.Object, e As System.EventArgs) Handles btn2.Click
    numberBins = "2"
    DialogResult = Windows.Forms.DialogResult.OK
End Sub

So why isn't my property being set?

AlexF11
  • 231
  • 1
  • 5
  • 20

1 Answers1

1

Your issue is here:

If TubeSelectTo.ShowDialog(currentWO, status) = Windows.Forms.DialogResult.OK Then

You are using the default instance of the TubeSelectTo form, rather than the SelectNextForm instance that you created.

Change it to:

If SelectNextForm.ShowDialog(currentWO, status) = Windows.Forms.DialogResult.OK Then
Community
  • 1
  • 1
Visual Vincent
  • 18,045
  • 5
  • 28
  • 75