Not sure why you're trying to use an array of TextBoxes. Here's how I would do it (one TextBox on a form):
Private _data As New ArrayList
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim iLp As Integer
Dim total As Integer
Dim average As Single
_data.Add(TextBox1.Text)
For iLp = 0 To _data.Count - 1
total += CType(_data(iLp), Integer)
Next iLp
Label1.Text = total.ToString
Label2.Text = (total / _data.Count).ToString
End Sub
Or, even easier:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Static count As Integer
Static total As Integer
count += 1
total += CType(TextBox1.Text, Integer)
Label1.Text = total.ToString
Label2.Text = (total / count).ToString
End Sub
If you're using .NET, there's no reason to use regular arrays that you have to manually resize. Let .NET handle it for you. :D :cool: