I have a VB6 method that returns an array of strings as a Variant.
When I try and convert this to a VB.NET string array, I receive the cast error. So, to get around this I do the following:
Dim a As Array = CTYPE(old.Method(), Array)
This does not throw an exception, so I therefore assume that the VB6 method is indeed returning an array object. However, I cannot cast this to a string array, even though each element in the Array 'a' is of type string.
Dim obj() As Object = CTYPE(old.Method(), Object()) produces the same error.
So, I cannot cast the returned Variant to an Object() / String(), but I can cast it to Array.
Furthermore, in VB.NET I would simply do,
Private Function a() As Object
Dim str(1) As String
Dim newStr() As String = CTYPE(a(), String())