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!

Recommended Answers

All 3 Replies

Private Sub submitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles submitButton.Click
        '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 & "           " & 1)
            Else
                Dim s As String = My.Forms.CompletedOrderForm.productListBox.Items(index).ToString.Replace(color1CheckBox.Text, "").Trim
                My.Forms.CompletedOrderForm.productListBox.Items(index) = color1CheckBox.Text & "           " & s + 1
            End If
        End If

        My.Forms.ConfirmationDialog.ShowDialog()
    End Sub

Thank you so much for helping me! No one would give me the time of day for a while there. I totally understand what you did, but it's still stuck on 2. Any more ideas?

hmm i dont really understand your problem tbh.
each time you click the button then quantity grows by 1 if the checkbox is checked.
can you please explain a bit more detailed?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.