arrays - Visual Basic 6 数组作为参数

标签 arrays vb6 parameter-passing

这可能听起来像一个愚蠢的问题,但我要拉出来听。

我有一个子,我想解析一个数组并将其分配给一个类模块“对象”。

我该怎么做。

我所拥有的不起作用的是:

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/

相关文章:

mysql - 如何将带逗号的字符串(VARCHAR)传递给存储过程?

sql - 我需要从sql中的二进制信息生成一个文件

vb6 - 为什么 VB6 .frm 文件会充满二进制文件?

c - 在辅助函数中设置两个指针相等

javascript - 指定要传递的参数

javascript - 从对象中获取键/值,执行功能并发回

javascript - 获取对象中数组的大小

javascript - 以下代码是否等待 forEach 完成

.net - vb6 到 vb.net dll 兼容版本

parameter-passing - 将具有今天日期的特定时间作为值传递给 Informatica Cloud 中的输入字段