Link to home
Start Free TrialLog in
Avatar of Charles Sugden
Charles SugdenFlag for United States of America

asked on

VB6 Handling a string array returned from a COM object

Hello,
I have the unsavory task of making a change to an old VB6 application.
The application needs to receive an array of errro messages from a COM object written in .NET.

I have been struggling with the code to get the individual array entries in printable form in VB6 with code similar to


dim o as object
set o = createobject("dotnet.app")
dim test as object
obj = o.errormessages

print obj(0)
print obj(1)
etc

it's been a while and my VB6 skills are rusty.

Thanks in advance

Charlie
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

I have never worked with .net objects in VB6, so I would have to test this out.
what does
print typename(obj) return?
what error message(s) do you get?
Avatar of Charles Sugden

ASKER

Sorry to respond so late. I was off on Fridat.
The return type was defintiely as string()

My latest attempt was
dim o as object
set o = createobject("dotnet.app")
dim test as variant
dim ar() as string
test = o.errormessages
arr=test

Still can seem to get the array elements displayed.
I get subscript out of bounds
can you please post
print lbound(test)
print ubound(test)
I get Subscript out of Range.

The tech jerk that i work for refuses to show me the code he wrote in the DLL.

I used isempty(test) and it returns false wehich leads me to believe that there is content in there but yet the string() property cannot be subscripted...
reading this, the array() from .net is rather a collection, not a vb6 array:
http://quickstart.developerfusion.co.uk/quickstart/howto/doc/Interop/TestServer_2.aspx
dim o as object
set o = createobject("dotnet.app")
dim test as variant
for each test in  o.errormessages
   print test
next 

Open in new window

Wow that sounds like the solution however I am getting an error message
"For Loop Not Initialized"

FYI: A test on o.errormessages using isempty was false
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg 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