Link to home
Start Free TrialLog in
Avatar of DFPITC
DFPITCFlag for Australia

asked on

How to reassign object to array in a loop

I have a function that returns an object array, lets say called oAryFunc, that I pass parameters.
I can't figure out how to assign it's output to an object in a loop
It keeps saying "Object reference not set to an instance of an object." on the second run of the loop
How do I reuse the "xAry" object?

Eg:

For Each param In paramlist
Dim xAry As Object = oAryFunc(param)
Next param

Function oAryFunc(ByVal param As String) As Object
'create array
Return oArray
End Function
SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland 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
Avatar of DFPITC

ASKER

That's what I tried first, which has the same error (doesn't seem to matter if it's declared within the loop or not)

I'm guessing it is assigning the reference to the xAry object, then the next iteration, the xAry object already has a reference, so it fails.
EXACTLY which line is failing with that error.
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
ASKER CERTIFIED 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 DFPITC

ASKER

See comment