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
Visual Basic