Re: strange arguments passing problem (from vba to fortran dll)



On May 29, 1:06 pm, Louis Krupp <lkr...@xxxxxxxxxxxxxxxxxxxxxxx>
wrote:
formulae translator wrote:
On May 29, 2:50 am, Arjen Markus <arjen.mar...@xxxxxxxxxx> wrote:
On 29 mei, 00:01, formulae translator <liwei19742...@xxxxxxxxx> wrote:

Dear all,
I encounter a strange problem when I am trying to pass arguments from
VBA (excel 2003) to fortran dll (compiled using CVF 6.6b).
debug in cvf environment shows some of the arguments are passed
correctly while some are not.
I attached part of the code here. The arguments passed correctly are
f_max, ppw, ma, para_H2. For other array arguments, only the first
elements are passed correctly.
any comments or suggestions are appreciated.
It looks as if only the scalar variables are passed correctly.
That does seem to make sense to me:

In VB you need to pass arrays like: ByRef array() As Double

In the code you posted the interfaces are missing the ().

Regards,

Arjen

Dear Arjen,

Thanks a lot for your prompt reply.

I tried the way you suggested, but got a compilor error (type
mismatch) from VBA.

The example in CVF document also has no "()" in "byref array as
double".

except for the two scalars (F_max and ppw), I have two arrays (ma and
para_H2) passed correctly.

I suspect the reason is that total size of arguments exceeds some
limit, but I am not sure because I cannot find any evidence to support
this.

Wei

You can test that hypothesis by stripping your code down to nothing but
variable initialization in VB and the Fortran subroutine call;
eliminate everything except for the subroutine arguments. If the values
look right when you do that, then the problem is elsewhere. Add
'implicit none' to the Fortran code -- it can save you some bugs later on.

Louis- Hide quoted text -

- Show quoted text -

Thanks for Louis' reply
I found the reason by playing with VBA part.
I can NOT define more than one array in one line.
It's so strange because I never heard anyone mentioned this.

The adjusted code should be following:

Dim f_max, ppw As Double

Dim i, j, nt_out, nlayer, n_ma As Long

Dim control(7) As Long
Dim ma(100) As Long

Dim acc(10000, 2) As Double
Dim profile(100, 4) As Double
Dim degradation(20, 200) As Double
Dim tabk(8, 3) As Double
Dim para_H2(10, 50) As Double

Dim node_depth(100) As Double
Dim layer_depth(100) As Double

Dim out_a(10000, 100) As Double

.



Relevant Pages

  • Re: Problems with result sets from stored procedures on a IBM AS400 DB
    ... > I got a strange problem while using VB6 and using stored procedures with a ... > Dim cn As ADODB.Connection ... > Dim cmd As ADODB.Command ... > If I am using the VB.Net the ado connection (without the provider in the ...
    (microsoft.public.vb.database.ado)
  • Problem with Datatable Insert
    ... I am experiencing a strange problem when inserting rows in a datatable ... Private Sub Insert_Row(ByVal sender As Object, ... Dim tbl As DataTable = New DataTable ... cell, the cell value reverts back to 0. ...
    (microsoft.public.dotnet.languages.vb)
  • Problem comparing double values
    ... I have a strange problem that I would appreciate any help ... Private Sub CompareNumbers() ... Dim arNumbersAs Double ... Dim dblComparison As Double ...
    (microsoft.public.vb.general.discussion)
  • VB, MDAC and progress database problem
    ... If the field contains a value ending with a zero, ... I've tried the same things with a C++ program, without this strange problem ... Dim Connection As Object ... Set Connection = CreateObject ...
    (microsoft.public.vb.database.ado)
  • VB and Progress database with ADO
    ... If the field contains a value ending with a zero, ... I've tried the same things with a C++ program, without this strange problem ... Dim Connection As Object ... Set Connection = CreateObject ...
    (microsoft.public.office.developer.vba)