Mega Code Archive

 
Categories / VB.Net Tutorial / Collections
 

Computing sum of elements in array

Module Tester    Sub Main()       Dim array As Integer() = New Integer() _          {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}       Dim total As Integer = 0, i As Integer = 0       For i = 0 To array.GetUpperBound(0)          total += array(i)       Next       Console.WriteLine("Total of array elements: " & total)    End Sub  End Module Total of array elements: 55