这可能听起来像一个愚蠢的问题,但我要拉出来听。
我有一个子,我想解析一个数组并将其分配给一个类模块“对象”。
我该怎么做。
我所拥有的不起作用的是:
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)
我收到以下错误消息:
类型不匹配:需要数组或用户定义的类型。
最佳答案
这有效:
'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
'类'
Private matrix() As Integer
'The Setter Sub '
Public Sub SetMatrixArray(arrValToSet() as Integer)
matrix = arrValToSet
End Sub
所以在你的类中删除矩阵数组的尺寸。如果维度必须恰好是 9,您始终可以实现错误检查。
编辑:我在测试时不假思索地删除了过程调用周围的括号,它可能会影响答案。
关于arrays - Visual Basic 6 数组作为参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6049684/