string passing to DLL

C

Christoph Wirz

How can I pass a string to a DLL?

I have written a DLL with Fortran. I can pass integers and reals from Excel
to my DLL and back. When I try to pass a string I get an error message
"stack too small" or even worse my excel application is closed.
The Excel part looks as follows:

Declare Sub REG_A Lib "C:\Daten\RegAn.dll" (Polyg As Long, Nmess As Long,
XMess As Double, filnam As String, Leverage As Double)
Dim filnam$
filnam = "C:\Daten\dll_mldg.txt"

Call REG_A([Polyg], [Nmess], XMess(0), filnam, Leverage(0))

What is wrong with the above? How can I pass a string to a DLL?

Thanks for any help

Christoph
 
B

BrianB

AFAIK Having declared the sub you just need to pass the comma delimite
variables without brackets (either as hard code or variable names)
This works with API calls. eg.

MySubroutine 1,"Astring"

If you want a returned value, you have to declare a function and us
the form :-

x = MyFunction MyNumberVariable, MyStringVariabl
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top