I'm trying to find out what is the final output value for this "for loops." I'm getting 81

Dim sum As Integer

sum = 0
For i As Integer = 1 To lstNumbers.Items.Count - 2
    sum = sum + lstNumbers.Items(i)
Next
lstNumbers.Items.Add("The sum is " & CStr(sum))

"lstNumbers.Items"
5
10
15
20
25
30

Not sure what exactlly you want but try this:
Debug.writeline(sum)
This will print out the current value of sum in your output window.

Not sure what exactlly you want but try this:
Debug.writeline(sum)
This will print out the current value of sum in your output window.

Geek,
Thank you for your replay, but I just trying to learn how for loops works.
The list of numbers Items supposed to loop and do an if statement every time
goes and take one number from the list. You suggestion works for other tracing.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.