title: How can I pass a double array to a form and use it in multiple subs?
body: <p>I already searched a lot but could not find a solution. I have a Form and in that Form I call another Form (let's say Form2). In Form 2 I can enter values in some textboxes and then I am passing these values as a double array back to Form 1:</p>
  
  <pre><code>Public Class Form1
    Dim a As Double
    Dim userDefined(3) As Double
    Dim Form_2 As Form2
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
  
      Form_2= New Form2       
      Form_2.ShowDialog()
      a = userDefined(0)
  
    End Sub
  
    Public WriteOnly Property setUserValues As Array
      Set(value As Array)
  
          userDefined = value
  
      End Set
    End Property
  End Class
  
  
  Public Class Form2
    Dim userDefined(0 To 3) As Double
  
  Private Sub Btn_transmitValues_Click(sender As System.Object, e As System.EventArgs) Handles Btn_transmitValues.Click
  
      userDefined(0) = Txt_1.Text
      userDefined(1) = Txt_2.Text
      userDefined(2) = Txt_3.Text
      userDefined(3) = Txt_4.Text
  
      Form1.setUserValues = userDefined
  
      Me.Dispose()
  
  End Sub
  
  End Class
  </code></pre>
  
  <p>Now I want to use the values from the passed double array of Form2 in Form1 in the Button1_Click Sub. But when I define my array in Form1 as </p>
  
  <pre><code>Dim userDefined(3) As Double
  </code></pre>
  
  <p>then a (also in Form1) is always 0. When I define my array in Form 1 as</p>
  
  <pre><code>Dim userDefined() As Double
  </code></pre>
  
  <p>then I get the error "Object reference not set to an instance of an object" but when I hover over a the right value is passed. What can I do to get the right value for a? Thanks in advance.</p>