vb 怎么创建控件数组对象

2024-11-26 01:22:45
推荐回答(2个)
回答1:

如果想要直接传递窗体上的控件数组,你的过程参数必须是集合形式:

call other(Frame1)
Sub other(My_frame As Collection)
My_frame(0).BackColor = vbGreen
My_frame(1).BackColor = vbRed

End Sub

回答2:

Private Sub Form_Load()
Dim a(3) As Frame
For i = 0 To UBound(a)
Set a(i) = Frame1(i)
Next
Call other(a)
End Sub

Sub other(My_frame() As Frame)
My_frame(0).BackColor = vbGreen
My_frame(1).BackColor = vbRed
My_frame(2).BackColor = vbBlue
End Sub