Converting VB6.0 external dll function call to Visual C++ .NET

Discussion in 'C++' started by Cyde Weys, Jul 6, 2004.

  1. Cyde Weys

    Cyde Weys Guest

    I'm currently working on converting a simulator program from Visual
    Basic 6.0 to Visual C++ .NET. I've figured out most of the stuff, but
    there's still one thing I haven't gotten to and I've never really had
    to deal with it before. I'm programming a front-end for what is a
    compiled Fortran program. The VB source does the following to call
    the Fortran:

    'Defines the subroutine.
    Declare Sub Cycle_DW Lib "cycdw.dll" Alias "CYCDW" (ByRef ncall As
    Long, ByRef tcr As Double, ByRef II As Long, ByRef XX As Double, ByRef
    xres As Double, ByVal AA As String, ByVal aaSize As Integer, ByVal
    ares As String, ByVal aresSize As Integer, ByVal ltable As String,
    ByVal ltableSize As Integer)

    'Actually calls the subroutine.
    Call Cycle_DW(lCycMode(1), dCritTemp(1), II(1), XX(1), xres(1), AA,
    480, ares, 4800, ltable, 37 * 80)

    The program is using 1-indexed arrays (hopefully it'll convert over to
    using 0-indexed arrays in C++ with no problems), and it's passing a
    pointer to the first element of each array. The numbers 480 and 4800
    are character lengths; two arrays are being passed to the program
    which are huge arrays of characters, with each 80 characters
    representing one string (kind of an awkward way to do it, I know, but
    that's how the Fortran program does it and I can't change that).

    So, how would I go about converting this to C++? Thanks in advance.
    Cyde Weys, Jul 6, 2004
    #1
    1. Advertising

  2. Cyde Weys

    Mike Wahler Guest

    "Cyde Weys" <> wrote in message
    news:...
    > I'm currently working on converting a simulator program from Visual
    > Basic 6.0 to Visual C++ .NET. I've figured out most of the stuff, but
    > there's still one thing I haven't gotten to and I've never really had
    > to deal with it before. I'm programming a front-end for what is a
    > compiled Fortran program. The VB source does the following to call
    > the Fortran:
    >
    > 'Defines the subroutine.
    > Declare Sub Cycle_DW Lib "cycdw.dll" Alias "CYCDW" (ByRef ncall As
    > Long, ByRef tcr As Double, ByRef II As Long, ByRef XX As Double, ByRef
    > xres As Double, ByVal AA As String, ByVal aaSize As Integer, ByVal
    > ares As String, ByVal aresSize As Integer, ByVal ltable As String,
    > ByVal ltableSize As Integer)
    >
    > 'Actually calls the subroutine.
    > Call Cycle_DW(lCycMode(1), dCritTemp(1), II(1), XX(1), xres(1), AA,
    > 480, ares, 4800, ltable, 37 * 80)
    >
    > The program is using 1-indexed arrays (hopefully it'll convert over to
    > using 0-indexed arrays in C++ with no problems), and it's passing a
    > pointer to the first element of each array. The numbers 480 and 4800
    > are character lengths; two arrays are being passed to the program
    > which are huge arrays of characters, with each 80 characters
    > representing one string (kind of an awkward way to do it, I know, but
    > that's how the Fortran program does it and I can't change that).
    >
    > So, how would I go about converting this to C++? Thanks in advance.


    The C++ language does not define an interface to other languages
    except to C. You'll need to peruse the documentation for your
    C++ implementation to find out how to link to FORTRAN (if it can
    do it at all). Also, how this would work also depends upon which
    FORTRAN implementation was used to build the function you're calling.

    -Mike
    Mike Wahler, Jul 6, 2004
    #2
    1. Advertising

  3. Cyde Weys

    Cyde Weys Guest

    "Mike Wahler" <> wrote in news:MuFGc.7306$oD3.1925
    @newsread1.news.pas.earthlink.net:

    > The C++ language does not define an interface to other languages
    > except to C. You'll need to peruse the documentation for your
    > C++ implementation to find out how to link to FORTRAN (if it can
    > do it at all). Also, how this would work also depends upon which
    > FORTRAN implementation was used to build the function you're calling.


    Awwww crap. So it's not as easy as it is in VB, is what you're saying.

    --
    ~ Cyde Weys ~
    Burn the land and boil the sea, you can't take the sky from me ...
    Cyde Weys, Jul 7, 2004
    #3
  4. Cyde Weys

    Pete C. Guest

    Cyde Weys wrote:
    > "Mike Wahler" <> wrote in
    > news:MuFGc.7306$oD3.1925 @newsread1.news.pas.earthlink.net:
    >
    >> The C++ language does not define an interface to other languages
    >> except to C. You'll need to peruse the documentation for your
    >> C++ implementation to find out how to link to FORTRAN (if it can
    >> do it at all). Also, how this would work also depends upon which
    >> FORTRAN implementation was used to build the function you're calling.

    >
    > Awwww crap. So it's not as easy as it is in VB, is what you're
    > saying.


    It is, it's just not on-topic here. You'll need to ask in a Win32 group,
    such as comp.os.ms-windows.programmer.win32.

    - Pete
    Pete C., Jul 7, 2004
    #4
  5. Cyde Weys

    Cyde Weys Guest

    "Pete C." <> wrote in news:5SIGc.7072$R36.4954
    @newsread2.news.pas.earthlink.net:

    > Cyde Weys wrote:


    >> Awwww crap. So it's not as easy as it is in VB, is what you're
    >> saying.

    >
    > It is, it's just not on-topic here. You'll need to ask in a Win32 group,
    > such as comp.os.ms-windows.programmer.win32.


    Thanks for the group recommendation, what the other guy just confused me
    and didn't help at all :-/

    --
    ~ Cyde Weys ~
    Burn the land and boil the sea, you can't take the sky from me ...
    Cyde Weys, Jul 7, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. awan

    Use .Net created dll in VB6?

    awan, Feb 25, 2004, in forum: ASP .Net
    Replies:
    8
    Views:
    43,722
    Noyabronok
    Oct 22, 2010
  2. Gary McGill
    Replies:
    9
    Views:
    4,833
    smith
    Dec 6, 2004
  3. Amelyan
    Replies:
    4
    Views:
    455
    Juan T. Llibre
    Nov 4, 2005
  4. Scott Allen
    Replies:
    8
    Views:
    10,929
    Scott Allen
    May 2, 2004
  5. Tom
    Replies:
    1
    Views:
    455
Loading...

Share This Page