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

Started by
2 comments, last by owl 13 years, 6 months ago
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 = arrend 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!
[size="2"]I like the Walrus best.
Advertisement
I found a way:

  Object[] myObj = myComClass.getArray();  for (int i=0; i < myObj.Lenght; i++)  {    Byte MyByte = Convert.ToByte(myObj);  }

[size="2"]I like the Walrus best.
A slightly terser way to express that would be

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

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

Cool! That's what I was looking for. Thanks!

EDIT: I cannot rate you any higher. lol
[size="2"]I like the Walrus best.

This topic is closed to new replies.

Advertisement