Page 1 of 1

Make DLL for VBA

Posted: Sat May 27, 2006 4:25 am
by oryaaaaa
This is a question from the demonstration user in Japan.
http://forum.oryaaaaa.com/viewtopic.php?p=169
Can you use it with VBA of Excel etc. by using DLL made with PureBasic?
Isn't there sample of DLL made with PureBasic that can be tested?
Thank you
I have not used VBA. It was not answered.
Could anyone teach?
Thank you

Posted: Sat May 27, 2006 8:28 am
by josku_x
VBA is Visual Basic for Applications. I think he wants to use an ActiveX DLL in Excel through VBA.

If you please could ask him if he wants to use an ActiveX DLL, I could help you.

Otherwise, I can give you an example if I find something. But, first it's better to know which DLL type the user wants.

Thanks.

Posted: Sat May 27, 2006 11:06 am
by oryaaaaa
Thanks. josku_x

The easy one was made and tested here.

Code: Select all

ProcedureDLL.l PlusCalc(a.l,b.l)
  ProcedureReturn a+b
EndProcedure 

Code: Select all

If OpenLibrary(0, "PlusCalc.dll")
   a=CallFunction(0, "PlusCalc",2,3)
   MessageRequester("", Str(a), #MB_OK)
   CloseLibrary(0)
EndIf 

Code: Select all

Private Declare Function PlusCalc Lib "PlusCalc.dll" ( _
    ByVal a As Long, _
    ByVal b As Long) As Long

Private Function ExcelPlusCalc(a As Long, b As Long) As Long
    ExcelPlusCalc = PlusCalc(a, b)
End Function 

Posted: Sat May 27, 2006 11:13 am
by josku_x
So he wanted a normal DLL and not an ActiveX DLL. Or did I miss something :?