[fpc-pascal] Writing DLLs to by used in Excel VBA code
luciano de souza
luchyanus at gmail.com
Fri Dec 11 20:15:55 CET 2015
Hello all,
I want to use a DLL writen in Pascal to provide functions for a Excel VBA code:
The example code of my DLL is:
library CE;
{$mode objfpc}
uses
Sysutils;
function level(x1, x2: integer): integer; cdecl; export;
begin
result := x1 + 2*x2;
end;
exports
level name 'level';
end.
In VBA, I did the following code:
Public Declare Function dlevel Lib "CE" Alias "level" (ByVal x1 As
Integer, ByVal x2 As Integer) As Integer
Function nivel(ByVal x1 As Integer, ByVal x2 As Integer) As Integer
nivel = dlevel(x1, x2)
End Function
In the sheet, I did:
=nivel(2;5)
And I got:
#value
I really don't know what to do. Seemlngly, VBA code is correct. I
don't know so much about DLLs, would be possible to have a mistake in
my Pascal code?
Does someone have any idea?
Best regards,
--
Luciano de Souza
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CE.pas
Type: text/pascal
Size: 183 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20151211/0000d73c/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CE.xlsm
Type: application/vnd.ms-excel.sheet.macroenabled.12
Size: 15366 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20151211/0000d73c/attachment-0001.bin>
More information about the fpc-pascal
mailing list