title: How to pass data from one form to another using a class (VB.Net)
body: <p>In my main program (form) I have two list boxes, one text box, and a button.
  When I pick two items in each list boxes and enter a number in the text box, it is suppsoed to be stocked in an array. I wanted to do this using a class. (I just asked a question about this, it works well now). The problem is I want to show the results in a different form.
  The code in my class looks like this:</p>
  
  <pre><code>Public Class Stocking
  
  
  Public sale(3, 4) As Integer
  Public numberSellers(3) As Integer
  Public numberProducts(4) As Integer
  
  
  Public Sub addItem(ByRef my_sellerListBox As ListBox, ByRef my_productListBox As ListBox, ByRef my_saleTextBox As TextBox)
      Dim sellerLineInteger As Integer
      Dim productColumnInteger As Integer
  
      sellerLineInteger = my_sellerListBox.SelectedIndex
      productColumnInteger = my_productListBox.SelectedIndex
  
      ' add in two dimensional array 
      If sellerLineInteger &gt;= 0 And productColumnInteger &gt;= 0 Then
          sale(sellerLineInteger, productColumnInteger) = Decimal.Parse(my_saleTextBox.Text)
      End If
  
      my_saleTextBox.Clear()
      my_saleTextBox.Focus()
  
      For sellerLineInteger = 0 To 3
          For productColumnInteger = 0 To 4
              numberSellers(sellerLineInteger) += sale(sellerLineInteger, productColumnInteger)
          Next productColumnInteger
      Next sellerLineInteger
  
  End Sub
  Public Sub showItems(ByRef my_label)
  
      my_label.Text = numberSellers(0).ToString 'using this as a test to see if it works for now
  
  
  End Sub
  End Class
  </code></pre>
  
  <p>My main form looks like this:</p>
  
  <pre><code>Public Class showForm
  
  Public sale(3, 4) As Integer
  Public numberSellers(3) As Integer
  Public numberProducts(4) As Integer
  
  Dim StockClass As New Stocking
  
      Public Sub addButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles addButton.Click
  
      StockClass.addItem(sellerListBox, producttListBox, saleTextBox)
  
  End Sub
  
  Public Sub SalesByMonthToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SalesByMonthToolStripMenuItem.Click
  
      saleForm.Show()
  </code></pre>
  
  <p>And in my second form, to show the results stocked in the array is:</p>
  
  <pre><code>Public Class saleForm
  
  Dim StockClass As New Stocking
  
  Public Sub saleForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  
      StockClass.showItems(Label00)
      'Only using one label as a test for now.
  
  End Sub
  
  End Class
  
  End Sub
  </code></pre>
  
  <p>I tested it and tried to see if the results shows on the main form, it does. So I'm guessing the problem is because I use a different form. Also I think it might be because I call the class again in my different form and doesn't keep the data.</p>