求vb锁定控件背景色代码

作者在 2014-06-28 14:46:53 发布以下内容

    在多个相同控件里,某一个控件变为红色后让其锁定,也就是当鼠标点击其他控件时,红色不再改变成白色。谢谢!请帮忙修改如下代码:

Private CurrenNum As Integer

Private Sub Command1_Click()

Picture2(i).BackColor = vbRed

End Sub


Private Sub Form_Load()

   CurrenNum = 0

   Call Picture2_Click(CurrenNum)

End Sub


Private Sub Label1_Click()


If CurrenNum < 35 Then

   CurrenNum = CurrenNum + 1

   Call Picture2_Click(CurrenNum)

End If

  

End Sub


Private Sub Label2_Click()


If CurrenNum > 0 Then

   CurrenNum = CurrenNum - 1

   Call Picture2_Click(CurrenNum)

End If


End Sub


Private Sub Picture2_Click(Index As Integer)


   Call 还原背景为白色

 

   Picture2(Index).Cls

   Picture2(Index).BackColor = &H80000003

   If i + 1 < 10 Then

      Picture2(Index).Print " " & CStr(Index + 1)

   Else

      Picture2(Index).Print CStr(Index + 1)

   End If

 

    CurrenNum = Index

 

End Sub


Private Sub 还原背景为白色()

Dim i As Integer

For i = 0 To 35

   Picture2(i).BackColor = vbWhite

   Picture2(i).Cls

   Picture2(i).Print CStr(i + 1)

Next i

End Sub


默认分类 | 阅读 1104 次
文章评论,共0条
游客请输入验证码
文章分类
文章归档
最新评论