Koe*_*box 4 arrays vb6 parameter-passing
这可能听起来像一个愚蠢的问题,但我即将拉出来.
我有一个Sub,我想解析一个数组并将其分配给类模块"对象".
我该怎么做呢
我所做的不起作用是:
Private matrix(9,9) As Integer
'The Setter Sub
Public Sub SetMatrixArray(arrValToSet() as Integer)
matrix = arrValToSet
End Sub
'In the caller module / class module I have the following code to parse the array.
Dim theArray(9,9) As Integer
Dim customObj as CustomObject
customObj.SetMatrixArray(theArray)
Run Code Online (Sandbox Code Playgroud)
我收到以下错误消息:
类型不匹配:预期的数组或用户定义类型.
这有效:
'In the caller module / class module I have the following code to parse the array.'
Dim theArray(9,9) As Integer
Dim customObj as CustomObject
customObj.SetMatrixArray theArray
Run Code Online (Sandbox Code Playgroud)
'班级'
Private matrix() As Integer
'The Setter Sub '
Public Sub SetMatrixArray(arrValToSet() as Integer)
matrix = arrValToSet
End Sub
Run Code Online (Sandbox Code Playgroud)
因此,删除类中矩阵数组的尺寸.如果维度必须精确为9,则始终可以实施错误检查.
编辑:我在测试过程中不假思索地移除了程序周围的parens,它可能会影响答案.