Dim aProductos As List(Of Producto)
Dim aRegistros As New List(Of Registro)
Dim selectedProd As New Producto
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'Add to cart
Dim insert As Boolean = True
Problem beginnt vvv HIERVB.net innerhalb einer Listenvariable Aktualisierung für jede Schleife
For Each reg In aRegistros
If (reg.id_prod = Integer.Parse(lbCodigo.Text)) Then
Dim r As New Registro
r.id_prod = reg.id_prod
r.cantidad = reg.cantidad + Integer.Parse(nudUni.Value.ToString)
reg = r
insert = False
End If
Next
PROBLEM AUSBAU HIER ^^^
If insert Then
Try
Dim r As New Registro
r.id_prod = selectedProd.cod
r.cantidad = Integer.Parse(nudUni.Value.ToString)
aRegistros.Add(r)
Catch ex As Exception
MsgBox("Create and insert register: " + ex.Message)
End Try
End If
MostrarFactura()
End Sub
Private Sub MostrarFactura() << Updates a listview to see the products you got
listaProd.Items.Clear()
For Each registro In aRegistros
For Each producto In aProductos
If registro.id_prod = producto.cod Then
MsgBox(registro.cantidad)
listaProd.Items.Add(producto.nombre + " --- " + registro.cantidad.ToString + " -> " + (producto.precio * registro.cantidad).ToString + "€")
End If
Next
Next
End Sub
Das Problem ist, dass ich aktualisieren " reg "aber wenn die Schleife endet reg aktualisiert nicht den Wert innerhalb der Liste
Vielen Dank im Voraus: S
Sie können der Liste, auf der Sie eine Enumeration mit foreach gestartet haben, nicht hinzufügen/entfernen. – Steve
Was kann ich stattdessen verwenden? Vielleicht nur mit einer While-Schleife? –
Sie können die Eigenschaft der aktuellen reg-Variablen ändern. _reg.cantidad = reg.cantidad + Integer.Parse (nudUni.Value.ToString); _ – Steve