Link to home
Start Free TrialLog in
Avatar of zagnutts
zagnutts

asked on

returning an array

I am trying to create a function that returns an array and I seem to be having a slight problem

'simplified function

Function TestFunc()
  dim temparry(1)

  tempArry(0)=0
  tempArry(1)=1
  TestFunc=tempArry
end Function


I then call this function in my page as follows
.....
dim arryA(1)

'initialize array
arryA(0)=0
arryA(1)=0

arryA=TestFunc()  'This is where I get an error "Type mismatch "


both arrays are the same size, so I don't see why there is a type mismatch.
Any help appreciated.









ASKER CERTIFIED SOLUTION
Avatar of amit_g
amit_g
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of djpierre
djpierre

try this

function makeArray()
       Dim tempArray(1)
      
       tempArray(0)="Melanie"
       tempArray(1)="Johanna"

       makeArray=tempArray
end function

dim myArray

myArray = makeArray()

for i=0 to UBound(myArray)
      Response.Write myArray(i)
next