2025年4月18日 星期五 乙巳(蛇)年 正月十九 设为首页 加入收藏
rss
您当前的位置:首页 > 计算机 > 编程开发 > VB

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

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

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

运行效果

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

程序代码

  • 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

 

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