有鬼的控件数组?!
我建了一个label的控件数组,从上到下依次排列。想实现以下效果:1,单击其中任意一个控件时,被单击者,背景变红色:另外两个背景透明
2,鼠标滑到任意一个控件上时,该控件背景变黄色(背景为红色者,除外) ;其余背景透明(背景为红色者,除外)。
3,鼠标滑到窗体上时,所有控件背景透明(背景为红色者,除外)。为此,我写了以下程序:
PART01: Private Sub Label1_Click(Index As Integer)
Select Case Index
Case 0
For Index = 0 To 2
If Label1(Index).BackColor = &H8080FF Then
Label1(Index).BackStyle = 0
End If
Next Index
Label1(0).BackStyle = 1
Label1(0).BackColor = &H8080FF
Case 1
For Index = 0 To 2
If Label1(Index).BackColor = &H8080FF Then
Label1(Index).BackStyle = 0
End If
Next Index
Label1(1).BackStyle = 1
Label1(1).BackColor = &H8080FF
Case 2
For Index = 0 To 2
If Label1(Index).BackColor = &H8080FF Then
Label1(Index).BackStyle = 0
End If
Next Index
Label1(2).BackStyle = 1
Label1(2).BackColor = &H8080FF
End Select
End Sub
PART02: Private Sub Label1_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
Select Case Index
Case 0
If Label1(0).BackColor = &H8080FF Then
Else
For Index = 0 To 2
If Label1(Index).BackColor = &HC0FFFF Then
Label1(Index).BackStyle = 0
End If
Next Index
Label1(0).BackStyle = 1
Label1(0).BackColor = &HC0FFFF
End If
Case 1
If Label1(1).BackColor = &H8080FF Then
Else
For Index = 0 To 2
If Label1(Index).BackColor = &HC0FFFF Then
Label1(Index).BackStyle = 0
End If
Next Index
Label1(1).BackColor = &HC0FFFF
Label1(1).BackStyle = 1
End If
Case 2
If Label1(2).BackColor = &H8080FF Then
Else
For Index = 0 To 2
If Label1(Index).BackColor = &HC0FFFF Then
Label1(Index).BackStyle = 0
End If
Next Index
Label1(2).BackStyle = 1
Label1(2).BackColor = &HC0FFFF
End If
End Select
End Sub
PART03: Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
For Index = 0 To 2
If Label1(Index).BackColor = &H8080FF Then
Else
Label1(Index).BackStyle = 0
End If
Next Index
End Sub
单独用PART01,可以实现单击效果
单独用PART02和PART03,可以实现滑动效果
可是,当三部分同时使用时,单击数次后,滑动效果就消失
why?