Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Converting VB6.0 external dll function call to Visual C++ .NET

Reply
Thread Tools

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

 
 
Cyde Weys
Guest
Posts: n/a
 
      07-06-2004
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.
 
Reply With Quote
 
 
 
 
Mike Wahler
Guest
Posts: n/a
 
      07-06-2004
"Cyde Weys" <> wrote in message
news: om...
> 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



 
Reply With Quote
 
 
 
 
Cyde Weys
Guest
Posts: n/a
 
      07-07-2004
"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 ...
 
Reply With Quote
 
Pete C.
Guest
Posts: n/a
 
      07-07-2004
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


 
Reply With Quote
 
Cyde Weys
Guest
Posts: n/a
 
      07-07-2004
"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 ...
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to call Visual C dll and .Net dll at clientside? Tom ASP .Net 1 09-14-2008 01:49 PM
a member function call an external function with same name yuanhp_china@hotmail.com C++ 0 02-09-2007 04:14 PM
write a function such that when ever i call this function in some other function .it should give me tha data type and value of calling function parameter komal C++ 6 01-25-2005 11:13 AM
unresolved external symbol/using an external dll Scott Allen C++ 8 05-02-2004 06:11 PM
msvcrt.dll, msvcirt.dll, msvcrt20.dll and msvcrt40.dll, explanation please! Snoopy NZ Computing 16 08-25-2003 12:34 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57