Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29273 Discussions

How to pass 2 dimensional arrays of strings from Visual Basic to Visual Fortran

uldry__pierre
Beginner
692 Views

Hello!

I understand that this topic has alreadybeen dealt with and I found the newsletter by Steve Lionel very useful (thank you) but I now would like adapt the code and pass a 2-dimensional array.As Steve Lionel shows, passing a vector works well and I was able to replicate thatbut with a 2-dimensional arraythis call:

iRes = SafeArrayGetElement(VBArray,i, LOC(StringPtr))

becomes problematic for me. I had hopedI couldchanged it to something where the "i" becomes an array such as for example(/2,2/). So I declared rgIndices(2)andusedthis:

iRes = SafeArrayGetElement(VBArray,rgIndices, LOC(StringPtr))

Unfortunately I got this error message "The shape matching rules of actual arguments and dummy arguments have been violated". So I tried to use:

iRes = SafeArrayGetElement(VBArray,rgIndices(1), LOC(StringPtr))

and that compiles but does not seem to work. Note that I tried to send 0-based positions and tried to have the second dimension in rgIndices(1) and the first dimension in rgIndices(2) etc... but it seems that I am just unable to pass the right location in the expected format so neverretrieve any pieces of text in VBarray.

I appreciate your help, thank you,
Pierre

0 Kudos
3 Replies
Steven_L_Intel1
Employee
692 Views
There's a provided sample, VB.NET-Safearrays, which illustrates how to access a multidimensioned array from VB.
0 Kudos
uldry__pierre
Beginner
692 Views
Hi Steve,

I see, thank you for your help. Now I also got the "old" way to workand I was wondering about the differences between the two pieces of code. Is the new way, using ifcom and then replacing SysStringByteLen()byConvertBSTRToString() and getting rid of the interface more efficient?

Thank you,
Pierre

0 Kudos
Steven_L_Intel1
Employee
692 Views
I don't know - am not entirely sure what the "old way" was. I can't get terribly excited about "efficiency" of this aspect of things - it will be overwhelmed by everything else.
0 Kudos
Reply