您当前的位置:首页 > 计算机 > 编程开发 > VB

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

时间:06-05来源:作者:点击数:

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

运行效果:

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(长整数),包含集合中的对象数目。

方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门