dim myControls as new Dictionary 显示用户类型未定义
既然是动态加入控件,干吗还需要用控件数组?
倘若你只是希望通过名称来管理这些控件,那么用一个集合或者集合集即可,例如:
dim myControls as new Dictionary
if not myControls.exists (controlName) then
myControls.add controlName, new Dictionary
end if
myControls(controlName).add controlIndex, Controls.Add("VB.CommandButton", "MyButton" & CStr(i))
此后,即可用 myControls(controlName)(contrlIndex) 来访问你所添加的任何一个控件