Incognetosoft Posted July 28, 2003 Posted July 28, 2003 :confused: I am writing an estimating software with VB.NET. I need to know the code to add up all the numbers in a listbox. If i have: 5 4 7 in ONE listbox, i need to know the code to put for the button to add them up! Please reply or preferably email me atemail me Quote
*Experts* Volte Posted July 28, 2003 *Experts* Posted July 28, 2003 Dim runningTotal As Int32 = 0 Dim s As String For Each s In ListBox1.Items Try runningTotal += Int32.Parse(s) Catch End Try LoopThat should do it. It just iterates the listbox and attempts to add the value to runningTotal. Quote
Incognetosoft Posted July 28, 2003 Author Posted July 28, 2003 Nope! :( No, that dosnt work..Lets say i have 2 fives in listbox 1 i wanta be able to click a button, and get a ten in textbox 1 Quote
*Experts* Volte Posted July 28, 2003 *Experts* Posted July 28, 2003 Other than the fact that I accidentally put Loop instead of Next at the end of the For loop, my code does exactly that. Just display runningTotal in a textbox. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.