vb WithEvents声明控件数组

来源:百度知道 编辑:UC知道 时间:2024/06/11 00:28:20
声明,绝对不用先添加控件再设置index=0的这种方法

Dim WithEvents Pic_bg As VB.PictureBox

Set Pic_bg = Controls.Add("VB.PictureBox", "Pic_bg", Picture1)
With Pic_bg
.Left = 10
.Top = 10
.Width = 4000
.Height = 600
.Appearance = 0
.BackColor = &H80000005
.BorderStyle = 0
.Visible = True

End With

这是单个控件的方法,可是我要的事控件数组,我把声明Dim WithEvents Pic_bg(10) As VB.PictureBox 却出现错误

使用withevents应注意下面的限制条件:
1、withevents不能派生对象变量
2、不能把withevents变量声明为 as new

【【【3 、不能用withevents创建变量数组!!】】】

看来你只能一个一个的声明了!!