Ch. 8 Programming Activity #1:
Create control array of 4 labels named lblNext(0) through lblNext(3).
In the Form Load event set the BackColor property of each one to a different color using the VB constants vbRed, vbBlue, vbGreen and vbYellow.
In the Click event for the control array, use a Select Case and the Index argument to change the BackColor of every control to the BackColor of the one which is clicked. Use a For loop within each Case of the Select Case structure if you can.
Solution:
Option Explicit
Private Sub Form_Load()
lblNext(0).BackColor = vbRed
lblNext(1).BackColor = vbBlue
lblNext(2).BackColor = vbGreen
lblNext(3).BackColor = vbYellow
End Sub
Private Sub lblNext_Click(Index As Integer)
Dim j As Integer
Select Case Index
Case 0
For j = 0 To 3
lblNext(j).BackColor
= vbRed
Next j
Case 1
For j = 0 To 3
lblNext(j).BackColor
= vbBlue
Next j
Case 2
For j = 0 To 3
lblNext(j).BackColor
= vbGreen
Next j
Case 3
For j = 0 To 3
lblNext(j).BackColor
= vbYellow
Next j
End Select
End Sub