Я сделал команду просмотра списка, где я нажимаю кнопку, и элемент автоматически появляется в списке просмотра.Список имеет 3 столбца: Список заказов, Прайс-лист и Количество.Я добавил кнопку, где он удаляет количество и уменьшает цену в соответствии с его информацией.Мне удалось удалить определенное количество, выбрав его, и оно работает только с одним элементом, но когда добавляется больше элементов, оно больше не работает.Заранее спасибо за помощь!
Программа : Удаление количества заказа : Еще добавлено предметов : Ошибкапроисходит здесь
Private Sub Button15_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
If olqlistview.SelectedItems.Count = 0 Then
Beep()
MessageBox.Show("Please select an item.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Else
Dim totale As Integer, pt As Integer, tp As Integer
Dim x As Integer = olqlistview.SelectedItems.Item(0).SubItems(2).Text, y As Integer = olqlistview.SelectedItems.Item(1).SubItems(1).Text
For i = 0 To olqlistview.SelectedItems.Count
If i = 1 Then
Dim lve As New ListViewItem
totale = Val(olqlistview.SelectedItems.Item(0).SubItems(2).Text) - 1
olqlistview.Items(0).SubItems(2).Text = CStr(totale)
tp = Val(y) / Val(x)
pt = Val(y) - Val(tp)
olqlistview.SelectedItems.Item(0).SubItems(1).Text = Val(pt)
End If
If x = 1 And i = 1 Then
olqlistview.Items.Remove(olqlistview.SelectedItems(0))
End If
Next
Dim lv As ListViewItem
Dim total As Long
Dim quantitytotal As Long
For Each lv In olqlistview.Items
total = total + CStr(lv.SubItems(1).Text)
quantitytotal = quantitytotal + CStr(lv.SubItems(2).Text)
Next
amtdue.Text = total
Label1.Text = total
tq.Text = quantitytotal
End If
End Sub
If olqlistview.SelectedItems.Count = 0 Then
Beep()
MessageBox.Show("Please select an item.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Else
Dim totale As Integer, pt As Integer, tp As Integer
Dim x As Integer = olqlistview.SelectedItems.Item(0).SubItems(2).Text, y As Integer = olqlistview.SelectedItems.Item(1).SubItems(1).Text
For i = 0 To olqlistview.SelectedItems.Count
If i = 1 Then
Dim lve As New ListViewItem
totale = Val(olqlistview.SelectedItems.Item(0).SubItems(2).Text) - 1
olqlistview.Items(0).SubItems(2).Text = CStr(totale)
tp = Val(y) / Val(x)
pt = Val(y) - Val(tp)
olqlistview.SelectedItems.Item(0).SubItems(1).Text = Val(pt)
End If
If x = 1 And i = 1 Then
olqlistview.Items.Remove(olqlistview.SelectedItems(0))
End If
Next
Dim lv As ListViewItem
Dim total As Long
Dim quantitytotal As Long
For Each lv In olqlistview.Items
total = total + CStr(lv.SubItems(1).Text)
quantitytotal = quantitytotal + CStr(lv.SubItems(2).Text)
Next
amtdue.Text = total
Label1.Text = total
tq.Text = quantitytotal
End If
End Sub