• Advertisement
Sign in to follow this  

returning a byte() array from Visual Basic 6 to .NET from an ActiveX DLL Method

This topic is 2683 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi!

I'm having problems with this, I need to cast an array of bytes from a VB6 ActiveX DLL reference method in a C# winform project.

the vb6 DLL would contain a method like


public function getArray() as byte()
dim arr
redim arr(0 to 100)
getArray = arr
end fuction


and then in .NET


myVBClass C = new myVBClass();

byte[] arr = (byte[])myVBClass.getArray();


But of course this isn't working.

How can I achieve this? Is it even possible? Should be done with strings?

Thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
I found a way:



Object[] myObj = myComClass.getArray();

for (int i=0; i < myObj.Lenght; i++)
{
Byte MyByte = Convert.ToByte(myObj);
}


Share this post


Link to post
Share on other sites
A slightly terser way to express that would be

byte[] arr = Array.ConvertAll(myVBClass.getArray(), Convert.ToByte);

Share this post


Link to post
Share on other sites
Cool! That's what I was looking for. Thanks!

EDIT: I cannot rate you any higher. lol

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement