VB编程:利用控件数组设置控件状态-38

114 阅读1分钟

运行效果:

VB编程:利用控件数组设置控件状态-38
\

程序代码:

Private Sub Form_Load()

    For i = 0 To Label1.Count - 1

        Label1(i).Caption = "移动鼠标"

    Next i

End Sub

\

Private Sub Label1_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)

    Dim mouseover As Boolean

    mouseover = (0 <= X) And (X <= Label1(Index).Width)

    

    If mouseover Then

        For i = 0 To Label1.Count - 1

            Label1(i).ForeColor = &H0&

        Next i

        Label1(Index).ForeColor = &HFF&

    End If

End Sub

\

学习总结:

    1、Count 返回 Long(长整数),包含集合中的对象数目。

\