looping through listbox items...
Hello, I am trying to loop through integer values of a list box and sum all the values. I have a class library where I set "mylist" to be a class which inherits the listbox controls. The function returns the first time I add something but only the first time.
This code is in my main form to call the function when a new value is added to the list box and display it in a textbox named txtSum:
txtSum.Text = Mylist1.addEm():
My function is as follows:
Public Function addEm()
Dim i As Integer
Dim total As Integer
With MyBase.Items
For i = 0 To .Count - 1
total += .Item(i)
Return total
Next
End With
End Function
Any insight is appreciated
-Garrett