3

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.

1
  • 3
    Leave off the parentheses after FunctionArray. You probably also shouldn't name your variable Array in SubroutineA, since that is the name of a built-in function. Commented Mar 22, 2013 at 5:39

1 Answer 1

5

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
Sign up to request clarification or add additional context in comments.

1 Comment

Hi, can you explain why this works?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.