-1

I'm using COM interface to 3rd part program to get information with my functions. (VS2017 and Framework 4.7.2).

I'm getting an error from Visual Studio: "Option Strict On disallows late binding" for the below function

'x, y, z, al, be, ga. as an array 
Protected Friend Shared Function GetComputedBRFPos(ByVal bodyElement As IScrBody, ByVal index As Integer) As Array
    Return bodyElement.getComputedBRFPos(p_index:=index)
End Function

It has a documentation at 3rd part tool i'm also writing the description.

VARIANTList getComputedBRFPos ()
Get current BRF position, creates an implicit solver if no solver is existing. Array elements: x, y, z, al, be, ga.

For an example i'm putting another function i'm using and getting no late binding error for below function.

Protected Friend Shared Function Get_sb_node_pos(ByVal bodyElement As IScrBody, ByVal childIndex As Integer) As Array
    Return bodyElement.get_sb_node_pos(p_childIndex:=childIndex)
End Function

And it's description at documentation.

VARIANTList get_sb_node_pos (int childIndex)
Get all elements of sb_node_pos as an array.

I think it causing for bodyElement.getComputedBRFPos(p_index:=index) "index" value but i don't know what's the exact problem and how to achieve.

djv
  • 15,168
  • 7
  • 48
  • 72
  • I assume it's because you can't unbox the content of the array unless explicitly casting it. Basically, the compiler doesn't know what's inside the array before returning it. – Alessandro Mandelli Jan 07 '19 at 10:38
  • @AlessandroMandelli yes maybe the reason is that but i'm getting an array list without defining the index at the function and use like that bodyElement.getComputedBRFPos() after that isn't it possible to get from main function like GetComputedBRFPos(Body)(i) ? –  Jan 07 '19 at 11:29
  • https://stackoverflow.com/a/2890050/17034 – Hans Passant Jan 07 '19 at 13:09
  • You might need to specify the array's type - If you're returning an array that contains strings, the end of your function declaration should, I think - don't quote me, something like `Friend Shared Function (your parameters here) As String()` rather than simply `As Array` – David Wilson Jan 07 '19 at 13:19

1 Answers1

0

From the documentation you posted, it seems like bodyElement.getComputedBRFPos doesn't take any parameters. In VB.NET, the () are optional for method without parameters. So your code end up looking like this.

Return bodyElement.getComputedBRFPos()(p_index:=index)

Which doesn't return an array but instead return an element of the array which is of type object.

You should remove the parameter, change the return type or show us the documentation of the method with the parameter you are trying to call.

Return bodyElement.getComputedBRFPos()
the_lotus
  • 12,668
  • 3
  • 36
  • 53