Passing and retriving of strings from VB 6 to Fortran 90 
Author Message
 Passing and retriving of strings from VB 6 to Fortran 90

Hello,

    Newbie here and I need your help.

    I am trying to pass some strings from VB 6.0 to a fortran 90 program and
then retrive the results (string) from Fortran 90 into VB 6.0

  Anyone has any idea how this can be done.

  Thanks very much for pointing me in the right direction

 Chin



Fri, 02 Dec 2005 12:14:11 GMT  
 Passing and retriving of strings from VB 6 to Fortran 90

Quote:

> Hello,

>     Newbie here and I need your help.

>     I am trying to pass some strings from VB 6.0 to a Fortran 90 program and
> then retrive the results (string) from Fortran 90 into VB 6.0

>   Anyone has any idea how this can be done.

>   Thanks very much for pointing me in the right direction

What compiler?  CVF has good mixed-language programming section and
samples...
try

http://h18009.www1.hp.com/fortran/docs/vf-html/vf_frame.htm



Fri, 02 Dec 2005 21:44:26 GMT  
 Passing and retriving of strings from VB 6 to Fortran 90

Quote:


> > Hello,

> >     Newbie here and I need your help.

> >     I am trying to pass some strings from VB 6.0 to a Fortran 90 program and
> > then retrive the results (string) from Fortran 90 into VB 6.0

> >   Anyone has any idea how this can be done.

> >   Thanks very much for pointing me in the right direction

> What compiler?  CVF has good mixed-language programming section and
> samples...
> try

> http://h18009.www1.hp.com/fortran/docs/vf-html/vf_frame.htm

Sorry, I intended to paste the following snippet from there, too,
although I'd recommend strongly reading the section as VB has special
requirements for strings and arrays in particular...

Visual Basic strings must be passed by value to Fortran. Visual Basic
strings are actually stored as structures containing length and location
information. Passing by value dereferences the structure and passes just
the string location, as Fortran expects.

For example:

 ! In Basic
  Declare Sub forstr  Lib "forstr.dll" (ByVal Bstring as String)
  DIM bstring As String * 40 Fixed-length string
  CALL forstr(bstring)
 ! End Basic code

 ! In Fortran
  SUBROUTINE forstr(s)
  !DEC$ ATTRIBUTES STDCALL :: forstr
  !DEC$ ATTRIBUTES REFERENCE :: s
  CHARACTER(40) s
  s = 'Hello, Visual Basic!'
  END

Obviously the Fortran side will be compiler-specific to incorporate the
equivalence of the STDCALL and REFERENCE directives of CVF...



Fri, 02 Dec 2005 21:55:14 GMT  
 Passing and retriving of strings from VB 6 to Fortran 90

Quote:



>> > Hello,

>> >     Newbie here and I need your help.

>> >     I am trying to pass some strings from VB 6.0 to a Fortran 90 program
>and
>> > then retrive the results (string) from Fortran 90 into VB 6.0

>> >   Anyone has any idea how this can be done.

>> >   Thanks very much for pointing me in the right direction

>> What compiler?  CVF has good mixed-language programming section and
>> samples...
>> try

>> http://h18009.www1.hp.com/fortran/docs/vf-html/vf_frame.htm

>Sorry, I intended to paste the following snippet from there, too,
>although I'd recommend strongly reading the section as VB has special
>requirements for strings and arrays in particular...

>Visual Basic strings must be passed by value to Fortran. Visual Basic
>strings are actually stored as structures containing length and location
>information. Passing by value dereferences the structure and passes just
>the string location, as Fortran expects.

>For example:

> ! In Basic
>  Declare Sub forstr  Lib "forstr.dll" (ByVal Bstring as String)
>  DIM bstring As String * 40 Fixed-length string
>  CALL forstr(bstring)
> ! End Basic code

> ! In Fortran
>  SUBROUTINE forstr(s)
>  !DEC$ ATTRIBUTES STDCALL :: forstr
>  !DEC$ ATTRIBUTES REFERENCE :: s
>  CHARACTER(40) s
>  s = 'Hello, Visual Basic!'
>  END

>Obviously the Fortran side will be compiler-specific to incorporate the
>equivalence of the STDCALL and REFERENCE directives of CVF...

Just a side thought here....

If you intend to use your code well into the future... or rather...  to
recompile your fortran code in the future...  you "might" give some
consideration to writing your string data to an intermediate disk file and have
the "other" program read it from there.  This method has the distinct advantage
of more portability over the long haul.  As Duane pointed out...  his solution
is specific to the DVF Fortran compiler and is not guaranteed with any other
compiler ( including later versions of the DVF ( now Intel )  compiler ).  
The actual passing mechanism which a fortran compiler implements is specific to
the compiler.  If you make an assumption such as "pass by reference" or "pass
by value" and things work ok,  just be clear that you can't necessarily depend
on that behavior.

Dan  :-)



Sat, 03 Dec 2005 08:53:37 GMT  
 Passing and retriving of strings from VB 6 to Fortran 90

Quote:

> Just a side thought here....

> If you intend to use your code well into the future... or rather...  to
> recompile your fortran code in the future...  you "might" give some
> consideration to writing your string data to an intermediate disk file and have
> the "other" program read it from there.  This method has the distinct advantage
> of more portability over the long haul.  As Duane pointed out...  his solution
> is specific to the DVF Fortran compiler and is not guaranteed with any other
> compiler ( including later versions of the DVF ( now Intel )  compiler ).
> The actual passing mechanism which a fortran compiler implements is specific to
> the compiler.  If you make an assumption such as "pass by reference" or "pass
> by value" and things work ok,  just be clear that you can't necessarily depend
> on that behavior.

Also consider, though, that similar facilities are necessary for
interop with Windows.  It's not guaranteed to be portable going
forward, but IMO it's unlikely to go away.  (It's not, however, as
likely to be portable to another platform.)


Sat, 03 Dec 2005 22:24:45 GMT  
 Passing and retriving of strings from VB 6 to Fortran 90

Quote:


> > Just a side thought here....

> > If you intend to use your code well into the future... or rather...  to
> > recompile your fortran code in the future...  you "might" give some
> > consideration to writing your string data to an intermediate disk file and have
> > the "other" program read it from there.  This method has the distinct advantage
> > of more portability over the long haul.  As Duane pointed out...  his solution
> > is specific to the DVF Fortran compiler and is not guaranteed with any other
> > compiler ( including later versions of the DVF ( now Intel )  compiler ).
> > The actual passing mechanism which a fortran compiler implements is specific to
> > the compiler.  If you make an assumption such as "pass by reference" or "pass
> > by value" and things work ok,  just be clear that you can't necessarily depend
> > on that behavior.

> Also consider, though, that similar facilities are necessary for
> interop with Windows.  It's not guaranteed to be portable going
> forward, but IMO it's unlikely to go away.  (It's not, however, as
> likely to be portable to another platform.)

Of course, as I was going to point out to Dan, if you're talking about
mixed language programming w/VB, you're pretty much saying you don't
give a hoot about portability anyway!! :)  And, as far as the "going
forward" bit, MS has already killed that w/.NET as VB5/6 have already
been relegated to the trashbin and the .NET incarnation is not at all
the same language as VB.


Sat, 03 Dec 2005 22:58:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. FORTRAN 90 with VB 4

2. mixed language programming - visual basic calls c++ and fortran 90

3. Fortran 90 comparison question

4. Passing VB strings to Lahey FORTRAN DLLs

5. Passing string argument from VB to Fortran

6. How do I pass a string to FORTRAN?

7. Passing string Arrays from Fortran DLL to Visual Basic

8. how do I pass a string to FORTRAN?

9. Passing String as argument to Fortran

10. Passing Arrays to Fortran DLL from VB

11. Passing arrays from FORTRAN dll from VB

12. String arguments between VB and a Fortran DLL (VB4-32/Powerstation 4.0/Win 95)

 

 
Powered by phpBB® Forum Software