function - 从 vbscript 中的函数返回二维数组

标签 function multidimensional-array vbscript return

我正在处理的程序有问题。 我想做的是让一个函数接受用户的输入并将该数据存储在一个数组中 对于小型测试目的,它是一个 3 x 3 阵列 通过回显所有存储的值,我已经让函数中的数组按照测试的方式工作。 但是,当我尝试将数组返回到调用它的子程序时,出现不匹配错误,我不确定自己做错了什么。

    Sub SubroutineA()
          Dim Array(2,2)

          Array = GetInfo()

    End Sub

    Function GetInfo()
          Dim FunctionArray(2,2)
          {input all data into array}
          GetInfo = FunctionArray()
    End Function

我能得到的任何帮助都会很棒,因为这对我来说是新的。

最佳答案

Cheran Shunmugavel 指出了正确的方向,但他的解释含糊不清。说清楚:

Sub SubroutineA()
      Dim Arr     ' <<<--- do not use parenthesis here and do not use
                  '        the reserved keyword "Array"
      Arr = GetInfo()
End Sub

Function GetInfo()
      Dim FunctionArray(2,2)
      ' {input all data into array}
      GetInfo = FunctionArray     ' <<<--- do not use parenthesis here
End Function

关于function - 从 vbscript 中的函数返回二维数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15562862/

相关文章:

Javascript函数引用错误

c++ - 重载运算符 * C++

c++ - 解引用指针给出一个地址

C 编程二维数组问题

C# 获取二维整数数组中最大值的索引值

vbscript - 强制 VBS 使用 cscript 而不是 wscript 运行

vbscript - 如何使用 Vbscript 覆盖和写入文本文件

c - 在 C 中使用文字值与计算值时答案不正确

c - 与C中Java NextInt类似的函数

scripting - VBScript 从 Shell 获取结果