I am trying to run a loop through an array of labels (called 'rank'), and make each label's text set to the value of a list of highscore's values.
Dim highScores As New List(Of Integer)
Dim rank() As Control = {Label1, Label2, Label3, Label4, Label5}
Private Sub High_Scores_Load(sender As Object, e As EventArgs) Handles MyBase.Load
highScores.Add(points)
highScores.Sort()
For index As Integer = 0 To highScores.Count()
rank(index).Text = highScores(index)
Next index
End Sub
When I run this, I get:
Object reference not set to an instance of an object
at line "rank(index).Text = highScores(index)
". I have tweaked a bit off the stuff and I think I'm using the control array incorrectly, but I can't find a way to use it correctly.