加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

数组 – Visual Basic 6数组作为参数

发布时间:2020-12-17 07:25:48 所属栏目:百科 来源:网络整理
导读:这可能听起来像一个愚蠢的问题,但我即将拉出来. 我有一个Sub,我想解析一个数组并将其分配给类模块“对象”. 我该怎么做呢 我所做的不起作用是: Private matrix(9,9) As Integer'The Setter SubPublic Sub SetMatrixArray(arrValToSet() as Integer) matrix
这可能听起来像一个愚蠢的问题,但我即将拉出来.

我有一个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,它可能会影响答案.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读