请问;如何向用户控件内传递数组?
我在工程里添加了一个用户控件
在 Command1 里 这样写;
Private Sub Command1_Click()
Dim a as long
Dim B(1 to 20) as long
Dim C as long
C = 0
For a = 1 to 20
C = C + 1
B(a) = C
Next
'现在要将 B 这个数组传给 用户控件 里,该如何实现? 谢谢!!!
End Sub
[解决办法]
一般情况下传 B(0) 就可以了!如下:(注意:控件端需为 BYREF)
Private Sub Form_Load() Dim arrCall(0 To 9) As String '... setParamsForArray arrCall(0)End SubPrivate Sub setParamsForArray(ByRef arrList() As String) '...End Sub
[解决办法]
类里面有个公共的方法
类代码:
public function aFun(A() as long,....) as long'public sub 也可以
函数过程
dim n1 as long,n2 as long
n1=lboubd(a)
n2=uBound(a)
dim i as long
i=a(m)'m大于等于n1,小于等于n2
end function
调用:
Private Sub Command1_Click()
Dim a as long
Dim B(1 to 20) as long
Dim C as long
dim cx as new yourclass
C = 0
For a = 1 to 20
C = C + 1
B(a) = C
Next
'现在要将 B 这个数组传给 用户控件 里,该如何实现? 谢谢!!!
i=cx.aFun(B,.....)
End Sub