I have a home work assignment due at the end of the week and im stuck on the last two problems and I am not sure how to make them happen using an array.

Assume the array nums contains a list of positive integers. In the following exercises, write a Function procedure that calculates the stated value with a For Each loop.

1. the sum of the numbers in the array

2. the average of the numbers in the array

3. the largest even number in the array (If there are no even numbers in the array, the Function procedure should return 0.)

4. the smallest number in the array

5. the number of two-digit numbers in the array

6. the number of even numbers in the array

This is what i have so far

Code:

Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim b() As Integer = {3, 9, 30, 24, 5}
Dim sum As Integer
Dim ave As Integer
Dim larg As Integer = b(0)
Dim small As Integer = b(0)
Dim Two As Integer
Dim even As Integer
For Each item As Integer In b
sum += item
Next
ListBox1.Items.Add("The sum of the array is " & Format(vbCrLf & sum))
For Each item As Integer In b
ave = CInt(sum / item)
Next
ListBox1.Items.Add("The average of the array is " & Format(vbCrLf & ave))
For i As Integer = 1 To b.Count - 1
If b(i) > larg Then
larg = b(i)
End If
Next
ListBox1.Items.Add("The largest number of the array is " & Format(vbCrLf & larg))
For i As Integer = 1 To b.Count - 1
If b(i) < small Then
small = b(i)
End If
Next
ListBox1.Items.Add("The smallest number in the array is " & Format(vbCrLf & small))
End Sub
End Class