Charles Sugden
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
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
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
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)
print lbound(test)
print ubound(test)
ASKER
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...
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
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
ASKER
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
"For Loop Not Initialized"
FYI: A test on o.errormessages using isempty was false
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
what does
print typename(obj) return?
what error message(s) do you get?