OK so you have code that is displaying Form2, I assume in your main form. It is probably calling ShowDialog
to show Form1. When that call returns it is then showing
Form2`. It is in this method that you'll need to capture the values from the listboxes in Form1. Note that I do not recommend you directly accessing controls between forms as this can cause maintenance issues. Therefore this is a multi-step process: 1) before Form1 closes it should store the selected listbox items into public properties on Form1. Form2 should expose similar properties to get/set the same items. The parent method (in main form I assume) that shows Form2 should grab the values from Form1 and pass them to Form2.
Form1 needs properties to expose the selected values. The property returns the selected customer and sugar level. I'm assuming your listbox is storing strings.
Public Class Form1
Public Property SelectedCustomer As String
Get
Return CType(Listbox1.SelectedItem, String)
End Get
Set (value as String)
Listbox1.SelectedItem = value
End Set
End Property
Public Property SelectedSugarLevel As String
Get
Return CType(Listbox2.SelectedItem, String)
End Get
Set (value as String)
Listbox2.SelectedItem = value
End Set
End Property
End Class
Form2 will need the same set of properties and the code should basically be the same (except perhaps the field names).
The method that is displaying Form2 will then copy the values from one form to another.
Dim form1 As New Form1()
...
form1.ShowDialog()
Dim form2 As New Form2()
form2.SelectedCustomer = form1.SelectedCustomer
form2.SelectedSugarLevel = form1.SelectedSugarLevel
form2.ShowDialog()