您当前的位置: 首页 >  彭世瑜

VB编程:将文本控件添加到集合Collection中-19

彭世瑜 发布时间:2016-11-21 13:10:32 ,浏览量:3

运行效果


程序代码
Dim aaa As Collection
Private Sub Command1_Click()
    Dim item As Control
    For Each item In aaa
        item.Text = "microsoft"   '对集合中所有TextBox的Text属性赋值
    Next item
End Sub

Private Sub Command2_Click()
    Unload Me
End Sub

Private Sub Form_Load()
    Set aaa = New Collection
    Dim tex As Control
    For Each tex In Me.Controls
        If TypeName(tex) = "TextBox" Then      '判断是否为TextBox
            aaa.Add tex, tex.Name                       '添加到集合
        End If
    Next tex
End Sub

关注
打赏
查看更多评论

彭世瑜

暂无认证

  • 3浏览

    0关注

    2727博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录