这可能听起来像一个愚蠢的问题,但我即将拉出来.
我有一个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)
我收到以下错误消息:
类型不匹配:预期的数组或用户定义类型.
解决方法
这有效:
'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,则始终可以实施错误检查.
编辑:我在测试过程中不假思索地移除了程序周围的parens,它可能会影响答案.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。