sandi70
10.12.14,19:03
Čaute machri

Viete mi niekto poradť s VBA?

V Buttone2 mám tento kód, ktorý funguje správne:


Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click

Dim a As Decimal = CInt(TextBox1.Text)
Dim b As Decimal = CInt(TextBox2.Text)
Dim c As Decimal = a - b
TextBox3.Text.Text = CStr(c)

ListView1.Items.Add(New ListViewItem({TextBox1.Text, TextBox2.Text, TextBox3.Text.ToString()}))


End Sub


Len že by som potreboval ešte v písať jeden kód do Buttonu2, ktorý by mi sčítaval tretí stĺpec z ListView do Label1.

Ak vie niekto poradiť vopred Ďakujem!!!
taiko
10.12.14,20:41
skus tuto otazkocku dat aj na stackoverflow.com. Myslim, ze tam sa skor dockas odpovede
sthruska
11.12.14,06:55
A prečo ho tam nenapíšeš? Čo Ti bráni?
PaloPa
11.12.14,10:42
Pre Excel VBA takto:




Sub Button2_Click()

Dim a As Integer ' = CInt(TextBox1.Text)
Dim b As Integer ' = CInt(TextBox2.Text)
Dim c As Integer ' = a - b
Dim s As Integer ' sum of c
Dim i As Integer

a = CInt(TextBox1.Text)
b = CInt(TextBox2.Text)
c = a - b

TextBox3.Text = CStr(c)

ListBox1.AddItem CStr(a)
ListBox1.List(ListBox1.ListCount - 1, 1) = CStr(b)
ListBox1.List(ListBox1.ListCount - 1, 2) = CStr(c)

For i = 0 To ListBox1.ListCount - 1
s = s + CInt(ListBox1.List(i, 2))
Next i

Label1.Caption = s

End Sub