Make DLL for VBA

Just starting out? Need help? Post your questions and find answers here.
User avatar
oryaaaaa
Addict
Addict
Posts: 825
Joined: Mon Jan 12, 2004 11:40 pm
Location: Okazaki, JAPAN

Make DLL for VBA

Post 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
josku_x
Addict
Addict
Posts: 997
Joined: Sat Sep 24, 2005 2:08 pm

Post 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.
User avatar
oryaaaaa
Addict
Addict
Posts: 825
Joined: Mon Jan 12, 2004 11:40 pm
Location: Okazaki, JAPAN

Post 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 
josku_x
Addict
Addict
Posts: 997
Joined: Sat Sep 24, 2005 2:08 pm

Post by josku_x »

So he wanted a normal DLL and not an ActiveX DLL. Or did I miss something :?
Post Reply