要么用 kkp30 朋友说的用控件数组;
也可以自己编写一个过程,带有颜蚂态庆色参数:闷握
Private Sub SetColor(ByVal NewColor)
Label1.ForeColor = NewColor
Label2.ForeColor = NewColor
Label3.ForeColor = NewColor
Label4.ForeColor = NewColor
Label5.ForeColor = NewColor
Label6.ForeColor = NewColor
Label7.ForeColor = NewColor
Label8.ForeColor = NewColor
Label9.ForeColor = NewColor
Label10.ForeColor = NewColor
End Sub
需要的时候,用需要的颜色作为参数闭拦,调用该过程只要一句代码
比如:蓝色
Call SetColor(vbBlue)
比如:红色
Call SetColor(vbRed)
将label控件放置窗体中,然后复制粘贴9个,将每一个的index属性依次设置为0到9.
For i = 1 To 10
祥陵清汪让 Controls("label" & Trim(Str(i))).ForeColor 谨前= vbBlue
Next
用控件数组做