Ok, I have been working on this for months now, and I am so close to having it work the way I want, but it's just not happening. Here's what I am trying to do:
My program is half a formulator, and half ordering system. Where I get stuck is the ordering system part. In one screen I have 5 check boxes that you can check for which products you want to order. The products you checked then get sent to another screen and put into a list box with a quantity variable that starts at 1 attached to it. Now, if you check the same product again, another time through the program, as of now, quantity accumulates to 2, which is good, that's what I want. My problem is I want quantity to keep accumulating, right now it accumulates to 2, then on a third pass through the program, it duplicates the entry, so now in the list box has the original product and quantity of 2, and another entry that has the product with quantity of 2. I'm about ready to pull my hair out on this one. PLEASE HELP! I'm so close, yet so far! I would much rather use a ListView, but I don't quite understand how they work. Here's the code:
Option Explicit On
Option Strict On
Public Class OrderRequest
Private Sub submitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles submitButton.Click
Dim quantity As Integer = 1
'add selected products to CompletedOrderForm.
If color1CheckBox.Checked Then
Dim index As Integer = My.Forms.CompletedOrderForm.productListBox.FindString(color1CheckBox.Text)
If index < 0 Then
My.Forms.CompletedOrderForm.productListBox.Items.Add(color1CheckBox.Text & " " & quantity)
Else
My.Forms.CompletedOrderForm.productListBox.Items.Remove(color1CheckBox.Text & " " & quantity)
quantity = quantity + 1
My.Forms.CompletedOrderForm.productListBox.Items.Add(color1CheckBox.Text & " " & quantity)
End If
End If
My.Forms.ConfirmationDialog.ShowDialog()
End Sub
Thank You!