This project has moved and is read-only. For the latest updates, please go here.

Trouble returning array to Object

Aug 14, 2012 at 3:46 AM

I have converted a VB.NET Excel Add-in project from VSTO in Visual Studio 2012 to NetOffice in #Develop. I've managed to work through most all of the issues, but haven't been able to figure out how to return the result of a function properly. I taught myself to program, so that's probably why I can't get it to work. My function looks something like this:

Function myFunction(Arg1 As String) As Object

If ThisCode0 Then
	Return {0, "Result"}
ElseIf ThisCode1
	Return {1, "Result1"}
Else ThisCode2
	Return {2, "Result2"}
End If

End Function

I end up with a result that looks something like this:

myFunction(0) = "This object does not have an indexer property"

myFunction(1) = "This object does not have an indexer property"


It worked fine in VSTO with VS2012, any idea why it's not working now?

Aug 16, 2012 at 4:41 PM

I was able to solve the problem by storing the array to return in a variable first prior to returning it:


Dim result(1) As Object

result = {0, "result"}
Return result