Newbie question - trying to call fortran dll from VB 
Author Message
 Newbie question - trying to call fortran dll from VB

Hi Folks,

I'm trying to incorporate a piece of fortran into an excel spreadsheet using
a VB call to a fortran dll, which is not something I've ever done before
so I'm feeling my way a bit. I've hit a problem which from my reading of
the manuals shouldn't happen, and I'm wondering if anyone can offer some
advice?

The problem occurs when I try to leave the Visual Basic editor and it tries
to compile the code. The "Declare" statement which I am using to declare
the fortran dll throws an error objecting to me passing any arguments to
it (to my mind at least, this seems to be what it is saying). The VB code
is shown at the end of this post. The error message is as follows:

--error msg--

Compile error:

Constants, fixed length strings, arrays, user-defined types and Declare statements
are not allowed as public members of object modules

---end of error msg---

Unfortunately, the only instructions I have found on doing what I want to
do seem to be 1994, so may be out of date and/or misleading.

The VB code follows - in the editor the Declare statement appears to be flagged
as being in a (General) (Declarations) section of the code, which my old
instructions sort of imply is right - but is it?

*Any* advice greatly appreciated.

Cheers

Ron

--VB code (first line is wrapped but actually is one line)---

Public Declare Sub furnace Lib "furnace_dll.dll" (ByRef ch4flow As Single,
ByRef ch4temp As Single, ByRef airflow As Single, ByRef airtemp As Single,
ByRef rmin As Single, ByRef rmtemp As Single, ByRef ptempk As Single, ByRef
volflow As Single)

Public Sub CommandButton1_Click()
Dim ch4flow As Single
Dim ch4temp As Single
Dim airflow As Single
Dim airtemp As Single
Dim rmin As Single
Dim rmtemp As Single
Dim ptempk As Single
Dim volflow As Single
ch4flow = Sheet1.Range("F4")
ch4temp = Sheet1.Range("G4")
airflow = Sheet1.Range("H4")
airtemp = Sheet1.Range("I4")
rmin = Sheet1.Range("J4")
rmtemp = Sheet1.Range("K4")
Call furnace(ch4flow, ch4temp, airflow, airtemp, rmin, rmtemp, ptempk, volflow)
TextBox1.Value = ptempk
TextBox1.Value = 1.5 * TextBox2.Value
End Sub

Private Sub CommandButton2_Click()
TextBox1.Value = " empty "
End Sub

Private Sub TextBox2_Change()

End Sub



Tue, 22 Mar 2005 10:01:17 GMT  
 Newbie question - trying to call fortran dll from VB
That's a VBA thing and I don't know about DLL's from VBA--sorry.  I
<think> it's doable, though...

That looks like it would work in VB5/6.  

Quote:

> Hi Folks,

> I'm trying to incorporate a piece of fortran into an excel spreadsheet using
> a VB call to a fortran dll, which is not something I've ever done before
> so I'm feeling my way a bit. I've hit a problem which from my reading of
> the manuals shouldn't happen, and I'm wondering if anyone can offer some
> advice?

> The problem occurs when I try to leave the Visual Basic editor and it tries
> to compile the code. The "Declare" statement which I am using to declare
> the fortran dll throws an error objecting to me passing any arguments to
> it (to my mind at least, this seems to be what it is saying). The VB code
> is shown at the end of this post. The error message is as follows:

> --error msg--

> Compile error:

> Constants, fixed length strings, arrays, user-defined types and Declare statements
> are not allowed as public members of object modules

> ---end of error msg---

> Unfortunately, the only instructions I have found on doing what I want to
> do seem to be 1994, so may be out of date and/or misleading.

> The VB code follows - in the editor the Declare statement appears to be flagged
> as being in a (General) (Declarations) section of the code, which my old
> instructions sort of imply is right - but is it?

> *Any* advice greatly appreciated.

> Cheers

> Ron

> --VB code (first line is wrapped but actually is one line)---

> Public Declare Sub furnace Lib "furnace_dll.dll" (ByRef ch4flow As Single,
> ByRef ch4temp As Single, ByRef airflow As Single, ByRef airtemp As Single,
> ByRef rmin As Single, ByRef rmtemp As Single, ByRef ptempk As Single, ByRef
> volflow As Single)

> Public Sub CommandButton1_Click()
> Dim ch4flow As Single
> Dim ch4temp As Single
> Dim airflow As Single
> Dim airtemp As Single
> Dim rmin As Single
> Dim rmtemp As Single
> Dim ptempk As Single
> Dim volflow As Single
> ch4flow = Sheet1.Range("F4")
> ch4temp = Sheet1.Range("G4")
> airflow = Sheet1.Range("H4")
> airtemp = Sheet1.Range("I4")
> rmin = Sheet1.Range("J4")
> rmtemp = Sheet1.Range("K4")
> Call furnace(ch4flow, ch4temp, airflow, airtemp, rmin, rmtemp, ptempk, volflow)
> TextBox1.Value = ptempk
> TextBox1.Value = 1.5 * TextBox2.Value
> End Sub

> Private Sub CommandButton2_Click()
> TextBox1.Value = " empty "
> End Sub

> Private Sub TextBox2_Change()

> End Sub



Tue, 22 Mar 2005 11:20:57 GMT  
 Newbie question - trying to call fortran dll from VB
Make the declare private. If you want it public, put it in a module.

Jason Bouzane


Quote:

> Hi Folks,

> I'm trying to incorporate a piece of fortran into an excel spreadsheet
using
> a VB call to a fortran dll, which is not something I've ever done before
> so I'm feeling my way a bit. I've hit a problem which from my reading of
> the manuals shouldn't happen, and I'm wondering if anyone can offer some
> advice?

> The problem occurs when I try to leave the Visual Basic editor and it
tries
> to compile the code. The "Declare" statement which I am using to declare
> the fortran dll throws an error objecting to me passing any arguments to
> it (to my mind at least, this seems to be what it is saying). The VB code
> is shown at the end of this post. The error message is as follows:

> --error msg--

> Compile error:

> Constants, fixed length strings, arrays, user-defined types and Declare
statements
> are not allowed as public members of object modules

> ---end of error msg---

> Unfortunately, the only instructions I have found on doing what I want to
> do seem to be 1994, so may be out of date and/or misleading.

> The VB code follows - in the editor the Declare statement appears to be
flagged
> as being in a (General) (Declarations) section of the code, which my old
> instructions sort of imply is right - but is it?

> *Any* advice greatly appreciated.

> Cheers

> Ron

> --VB code (first line is wrapped but actually is one line)---

> Public Declare Sub furnace Lib "furnace_dll.dll" (ByRef ch4flow As Single,
> ByRef ch4temp As Single, ByRef airflow As Single, ByRef airtemp As Single,
> ByRef rmin As Single, ByRef rmtemp As Single, ByRef ptempk As Single,
ByRef
> volflow As Single)

> Public Sub CommandButton1_Click()
> Dim ch4flow As Single
> Dim ch4temp As Single
> Dim airflow As Single
> Dim airtemp As Single
> Dim rmin As Single
> Dim rmtemp As Single
> Dim ptempk As Single
> Dim volflow As Single
> ch4flow = Sheet1.Range("F4")
> ch4temp = Sheet1.Range("G4")
> airflow = Sheet1.Range("H4")
> airtemp = Sheet1.Range("I4")
> rmin = Sheet1.Range("J4")
> rmtemp = Sheet1.Range("K4")
> Call furnace(ch4flow, ch4temp, airflow, airtemp, rmin, rmtemp, ptempk,
volflow)
> TextBox1.Value = ptempk
> TextBox1.Value = 1.5 * TextBox2.Value
> End Sub

> Private Sub CommandButton2_Click()
> TextBox1.Value = " empty "
> End Sub

> Private Sub TextBox2_Change()

> End Sub



Tue, 22 Mar 2005 12:30:21 GMT  
 Newbie question - trying to call fortran dll from VB
Ah...you're right!  Forgot about that....it isn't a VBA thingy at all...
Quote:

> Make the declare private. If you want it public, put it in a module.

> Jason Bouzane



> > Hi Folks,

> > I'm trying to incorporate a piece of fortran into an excel spreadsheet
> using
> > a VB call to a fortran dll, which is not something I've ever done before
> > so I'm feeling my way a bit. I've hit a problem which from my reading of
> > the manuals shouldn't happen, and I'm wondering if anyone can offer some
> > advice?

> > The problem occurs when I try to leave the Visual Basic editor and it
> tries
> > to compile the code. The "Declare" statement which I am using to declare
> > the fortran dll throws an error objecting to me passing any arguments to
> > it (to my mind at least, this seems to be what it is saying). The VB code
> > is shown at the end of this post. The error message is as follows:

> > --error msg--

> > Compile error:

> > Constants, fixed length strings, arrays, user-defined types and Declare
> statements
> > are not allowed as public members of object modules

> > ---end of error msg---

> > Unfortunately, the only instructions I have found on doing what I want to
> > do seem to be 1994, so may be out of date and/or misleading.

> > The VB code follows - in the editor the Declare statement appears to be
> flagged
> > as being in a (General) (Declarations) section of the code, which my old
> > instructions sort of imply is right - but is it?

> > *Any* advice greatly appreciated.

> > Cheers

> > Ron

> > --VB code (first line is wrapped but actually is one line)---

> > Public Declare Sub furnace Lib "furnace_dll.dll" (ByRef ch4flow As Single,
> > ByRef ch4temp As Single, ByRef airflow As Single, ByRef airtemp As Single,
> > ByRef rmin As Single, ByRef rmtemp As Single, ByRef ptempk As Single,
> ByRef
> > volflow As Single)

> > Public Sub CommandButton1_Click()
> > Dim ch4flow As Single
> > Dim ch4temp As Single
> > Dim airflow As Single
> > Dim airtemp As Single
> > Dim rmin As Single
> > Dim rmtemp As Single
> > Dim ptempk As Single
> > Dim volflow As Single
> > ch4flow = Sheet1.Range("F4")
> > ch4temp = Sheet1.Range("G4")
> > airflow = Sheet1.Range("H4")
> > airtemp = Sheet1.Range("I4")
> > rmin = Sheet1.Range("J4")
> > rmtemp = Sheet1.Range("K4")
> > Call furnace(ch4flow, ch4temp, airflow, airtemp, rmin, rmtemp, ptempk,
> volflow)
> > TextBox1.Value = ptempk
> > TextBox1.Value = 1.5 * TextBox2.Value
> > End Sub

> > Private Sub CommandButton2_Click()
> > TextBox1.Value = " empty "
> > End Sub

> > Private Sub TextBox2_Change()

> > End Sub



Tue, 22 Mar 2005 21:47:38 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. File I/O in Fortran DLL called from VB 5

2. calling fortran dlls from VB

3. MS FORTRAN DLLs called by VB 5.0

4. Help: Calling Fortran-DLL with VB 4.0

5. VB call to Fortran DLL

6. OVERFLOW ERROR: Calling FORTRAN DLL in VB

7. Calling Fortran DLL from VB

8. VB calling a FORTRAN DLL

9. Calling a method in a vb dll from html page - newbie question

10. Newbie trying to read DLL exports from within VB

11. call-back functions in a fortran dll

12. Calling Fortran 77 dll's from Visual Basic under Excel

 

 
Powered by phpBB® Forum Software