<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Calling fortran from Visual Basic in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/Calling-fortran-from-Visual-Basic/m-p/965800#M22823</link>
    <description>&lt;A href="http://www.canaimasoft.com/f90VB/OnlineManuals/UserManual/default.htm" target="_blank"&gt; Canaimasoft's f90VB user manual&lt;/A&gt; is a quite worthwhile reference.</description>
    <pubDate>Thu, 06 Sep 2001 17:38:22 GMT</pubDate>
    <dc:creator>Jugoslav_Dujic</dc:creator>
    <dc:date>2001-09-06T17:38:22Z</dc:date>
    <item>
      <title>Calling fortran from Visual Basic</title>
      <link>https://community.intel.com/t5/Software-Archive/Calling-fortran-from-Visual-Basic/m-p/965798#M22821</link>
      <description>I'm trying to pass a structure from VB to fortran like " &lt;BR /&gt;type aaa  &lt;BR /&gt;   val1 as integer &lt;BR /&gt;   car as string  &lt;BR /&gt;   str (1 to 5) as string &lt;BR /&gt;end type &lt;BR /&gt; &lt;BR /&gt;dopes anyone know how to do that or any website that has a sample ? &lt;BR /&gt; &lt;BR /&gt;Thanks</description>
      <pubDate>Tue, 04 Sep 2001 23:43:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Calling-fortran-from-Visual-Basic/m-p/965798#M22821</guid>
      <dc:creator>swafortran</dc:creator>
      <dc:date>2001-09-04T23:43:03Z</dc:date>
    </item>
    <item>
      <title>Re: Calling fortran from Visual Basic</title>
      <link>https://community.intel.com/t5/Software-Archive/Calling-fortran-from-Visual-Basic/m-p/965799#M22822</link>
      <description>This is actually an interesting, if tedious, example of the special cases of passing UDTs to Fortran from VB. &lt;BR /&gt;OK, here we go. &lt;BR /&gt; &lt;BR /&gt;Note that because the UDT contains a string element, VB will create a copy of the UDT that contains an ANSI BSTR element and pass that instead of the real address of the UDT which contains UNICODE BSTRs.  Basically, VB is doing copy-in/copy-out.  The nice side of this is that you don't have to do the conversion from UNICODE yourself on the Fortran side of things. &lt;BR /&gt; &lt;BR /&gt;The first element of the VB UDT is "val1 as Integer".  This is a 2 byte integer (INTEGER*2).  Note that VB pads UDTs to four byte boundaries, so you must account for that when you create the corresponding f90 TYPE on the Fortran side of things.  Also, remember to use the SEQUENCE keyword. &lt;BR /&gt; &lt;BR /&gt;The second element of the VB UDT is "car as string".  Note that the passed UDT has a pointer to an ANSI BSTR here.  So the f90 TYPE should contain a 4-byte integer here to hold the ANSI BSTR. &lt;BR /&gt; &lt;BR /&gt;The third element of the VB UDT is "str (1 to 5) as string".  OK.  This is a good one too.  This is a SafeArray of BSTRs.  Of course, as mentioned below, the copy of the UDT that is passed on copy-in will be a SafeArray of ANSI BSTRs.  But since this is a fixed size array in a UDT, the SafeArrayDescriptor is not passed at all, instead the SafeArray data is passed inline in the UDT.  So what will be passed is 5 pointers (in a row in memory) to ANSI BSTRs.  So an array of five 4-byte integers should do the trick here, inside the f90 type.  &lt;BR /&gt; &lt;BR /&gt;Other notes.  You can use integer pointers to access the ANSI BSTRs inside your Fortran code.  Be careful of whether you intend to modify the string elements of the UDT in your Fortran code.  If you must modify the strings the dangerous way is to modify NO MORE than the length of the BSTRs (found by examining the 4 byte integer passed just prior to the address of the ANSI BSTR - or use SysStringByteLen on the BSTR).  The correct way to modify the strings is through the use of the functions SysStringByteLen, SysAllocStringByteLen, and SysFreeString.  See the CVF Mixed Lang VB programming sample ARRAYS for more info on this if you wish. &lt;BR /&gt; &lt;BR /&gt;If you want to see an example of your query, check out: &lt;BR /&gt;VB form - &lt;A href="http://www.termine.org/f90/VB_UDT/VB_UDTwithStrArr.html" target="_blank"&gt;http://www.termine.org/f90/VB_UDT/VB_UDTwithStrArr.html&lt;/A&gt; &lt;BR /&gt;CVF dll routine - &lt;A href="http://www.termine.org/f90/VB_UDT/UDT_Sample.html" target="_blank"&gt;http://www.termine.org/f90/VB_UDT/UDT_Sample.html&lt;/A&gt; &lt;BR /&gt; &lt;BR /&gt;After all this you may decide not to pass this structure, but it's up to you.  ;-) &lt;BR /&gt; &lt;BR /&gt;hth, &lt;BR /&gt;John</description>
      <pubDate>Wed, 05 Sep 2001 14:20:55 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Calling-fortran-from-Visual-Basic/m-p/965799#M22822</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-09-05T14:20:55Z</dc:date>
    </item>
    <item>
      <title>Re: Calling fortran from Visual Basic</title>
      <link>https://community.intel.com/t5/Software-Archive/Calling-fortran-from-Visual-Basic/m-p/965800#M22823</link>
      <description>&lt;A href="http://www.canaimasoft.com/f90VB/OnlineManuals/UserManual/default.htm" target="_blank"&gt; Canaimasoft's f90VB user manual&lt;/A&gt; is a quite worthwhile reference.</description>
      <pubDate>Thu, 06 Sep 2001 17:38:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Calling-fortran-from-Visual-Basic/m-p/965800#M22823</guid>
      <dc:creator>Jugoslav_Dujic</dc:creator>
      <dc:date>2001-09-06T17:38:22Z</dc:date>
    </item>
  </channel>
</rss>

