Dobrý deň
Prosim Vás viete mi poradiť s týmto kódom?
Tretí stlpec z ListView mi počíta správne do TextBoxu9, ale siedmy a osmi stlpec mi nesčíta a podčiarkne my SUM.. To znamená, že sa nemá opakovať SUM. Dá sa to nejak inak z kombinovať? Ďakujem za každú radu...
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
Dim a As Decimal = CDec(TextBox1.Text) 'Zač. Stav
Dim b As Decimal = CDec(TextBox2.Text) 'Kon. Stav
Dim c As Decimal = b - a 'Celková Spotreba
TextBox3.Text = CDec(c) 'Celková Spotreba
Dim sum As Decimal = TextBox3.Text("Celková Spotreba")
For i As Integer = 0 To ListView1.Items.Count - 1
sum = sum + CDec(ListView1.Items(i).SubItems(2).Text)
Next
TextBox9.Text = sum("Celková Spotreba")
Dim s As Decimal = CDec(TextBox3.Text) 'Celková Spotreba
Dim d As Decimal = CDec(TextBox4.Text) 'Cena za 1 K/W
Dim f As Decimal = CDec(TextBox6.Text) 'Nájom za Hod.
Dim g As Decimal = c * d + f 'Ceana za Spotrebu
TextBox7.Text = CDec(g) 'Cena za Spotrebu
Dim sum As Decimal = TextBox7.Text("Cena za Spotrebu")
For i As Integer = 0 To ListView1.Items.Count - 1
sum = sum + CDec(ListView1.Items(i).SubItems(6).Text)
Next
TextBox10.Text = sum("Cena za Spotrebu")
Dim k As Decimal = CDec(TextBox7.Text) 'Cena za Spotrebu
Dim m As Decimal = CDec(TextBox5.Text) 'Mes. Záloha
Dim t As Decimal = m - k 'Prep. a Nedop.
TextBox8.Text = CDec(t) 'Prep. a Nedop.
Dim sum As Decimal = TextBox8.Text("Prep. a Nedop.")
For i As Integer = 0 To ListView1.Items.Count - 1
sum = sum + CDec(ListView1.Items(i).SubItems(7).Text)
Next
TextBox11.Text = sum("Prep. a Nedop.")
ListView1.Items.Add(New ListViewItem({TextBox1.Text, TextBox2.Text, TextBox3.Text, TextBox4.Text, TextBox5.Text, TextBox6.Text, TextBox7.Text, TextBox8.Text.ToString()}))