以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  关于窗口控件Count的问题  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=145759)

--  作者:hongye
--  发布时间:2020/2/6 19:06:00
--  关于窗口控件Count的问题
查询窗口的控件代码是:
Dim n As Integer = e.Form.Controls.Count
MessageBox.Show("控件数量:" & n)

那查询窗口TextBox的数量的代码怎么写?

--  作者:有点蓝
--  发布时间:2020/2/7 9:38:00
--  
只能遍历

dim cnt as integer
For Each c As WinForm.Control In e.Form.Controls
    If
 Typeof c Is WinForm.TextBox Then \'判断控件是否是文本框
     
cnt += 1
    End
 If
Next

MessageBox.Show("控件数量:" & cnt )