Re-Initial variable to zero
My program has a class level variable calls sum. I am using this value to track a running total when click on Button7_Click. The sum value is displayed in a text box calls pricelst1.Text. I would like to reset this sum value to 0 when I click a button calls Button8_Clickon on my form. Below is my code. Any help would be greatly appreciated:
Dim sum As Double = 0
Dim list As String
Dim total2a As Double
Dim totalkit, total2ip, total2, totalsp, totalfat, totalipt, totalmfp, totalrb, total2cb, totalicb, totalgcb, totalmfpg As Double
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
sum = totalkit + total2ip + total2 + totalsp + totalfat + totalipt + totalmfp + totalrb + total2cb + totalicb + totalgcb + totalmfpg
pricelst1.Text = CStr(sum)
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
'reset sum to 0 and clear all txt boxes.
sum = 0
pricelst1.Clear()
qtytxt.Clear()
ListBox1.Items.Clear()
ListBox2.Items.Clear()
End Sub
|