I have many buttons on a form (8 across and 8 down). The buttons that are aligned vertically are arranged in a control array and I have named them "cmdOut1(0)...cmdOut1(7)". The next column is "cmdOut2(0)...cmdOut2(8)" ... . I want to be able to use the same sub by replacing the number in cmdOut1(0) with the value of n. Example of the this is:

private Sub ChangeColor(a as Integer, n as integer)
If cmdout1(a).BackColor = &HFF& then 'replace 1 with n
cmdout1(a).BackColor = &HC0C000 'replace 1 with n
else
cmdout1(a).BackColor = &HFF& 'replace 1 with n
End If
end sub



I want to be able to replace the 1 with n above. This way I don't have to create 8 subs that do the same thing.

The button that is clicked

private Sub cmdout1_Click(Index as Integer)
ChangeColor (Index, 1)
End Sub

'The next column would be

private Sub cmdout2_Click(Index as Integer)
ChangeColor (Index, 2)
End Sub




Is this possible?
Any help would be appreciated.