Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

returning a two dimensional array from a function in vbscript

im having an issue with a program im working on. what im trying to do is have a function accept input from a user and store that data in an array for small testing purposes it is a 3 x 3 array i have gotten the array within the function to work as tested by echoing out all values stored. however when i attempt to return the array to the sub from which it is called i get mismatch errors, im not sure what i am doing wrong.

    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

Any Help i could get would be great as this is new to me.

like image 421
zyther Avatar asked May 08 '26 15:05

zyther


1 Answers

Cheran Shunmugavel points to the right direction, but his explanation contains an ambiguety. To make it clear:

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
like image 100
AutomatedChaos Avatar answered May 11 '26 08:05

AutomatedChaos