DFPITC
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
EXACTLY which line is failing with that error.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
See comment
ASKER
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.