Question

I am making an inventory program. I am having trouble with setting up an alternative form to ship inventory.

I thought that my code below would take the entered number by the user, subtract it from the number stored in the array and then save the new number into the array.

Any resources that you know of online would be great.

Public Class Ship

  Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click

    If VBProj2.cbInventory.SelectedIndex <> -1 Then
      'VBProj2.cbInventory.Items.RemoveAt(VBProj2.cbInventory.SelectedIndex)
      VBProj2.txtQuantity.Clear()

      Dim intX As Integer = VBProj2.cbInventory.Items.Count
      If txtQuantityNew.Text <= 200 Then
        VBProj2.iquantity(intX) = txtQuantityNew.Text - VBProj2.iquantity(intX)

        MessageBox.Show(VBProj2.iquantity(intX))
        VBProj2.cbInventory.SelectedIndex = VBProj2.cbInventory.Items.Count - 1
      Else
        MessageBox.Show("Please only ship 200 or less")
      End If
      Me.Close()
    Else
      MessageBox.Show("Something fed up")
    End If

  End Sub

End Class
Was it helpful?

Solution

In your code here

VBProj2.iquantity(intX) = txtQuantityNew.Text - VBProj2.iquantity(intX)

Your actually subtracting the initial quantity from the new quantity, the opposite of how you said you wanted to do it, which would be

VBProj2.iquantity(intX) = VBProj2.iquantity(intX) - val(txtQuantityNew.Text)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top