Using VBA to a DLL created in VB6
Hello,
As the subject I'm trying to create a dll to use in VBA within Excel. I went to VB6 (which I do not know well) after trying in VB.NET and VC + +. NET because the dll must be COM (ActiveX). But I do not understand how to create a dll readable VBA because I have always problems of "entry point" or initialization of the dll.
Do give me a step by step?
Thanks
Re: Using VBA to a DLL created in VB6
Well, we first reduce to zero the errors on DLL ...
Creating DLL in VB6 is quite simple.
First you must open a new project, such as "ActiveX DLL".
This creates a class of default ...
Immediately afterwards go on property tax and some important things:
You must rename the first (before saving) the project with a more meaningful name of "Project1".
Also enter a description "intelligent" in "Project Description", because in many cases it will be the only voice that you will find the lists of the various references used when you will need to import!
You can take the first (and only) class in the "Forms of Class" DLL, delete and / or add others.
I guess you already know everything or almost Property Let / Get Property, Functions or Subs (future methods of DLL ...)
Re: Using VBA to a DLL created in VB6
we say that as a result of these questions going to read something more (holy google !)... I do not want you to waste time on things that I can find on the internet ... I thank you instead of the "straight" ... that sometimes make the difference.
go with the two part of the explanation
Re: Using VBA to a DLL created in VB6
Quote:
go with the two part of the explanation
Ok, say you have now your beautiful DLL "NomeDll.Dll" properly completed and running, which has 1 class ClasseDll ", which exposes eg. a method ". MetodoDll".
Also in the "Project Description" for example you had specified. "My First DLL v1.0.
Open a new Excel workbook, go into the VBA (the pages with the code ...), then Tools / References. In the list of the many available Ref should already have "My First DLL v1.0. If there is you can always look for the DLL manually with Browse ...
Once added to the Ref workbook, the code key to use the DLL is as follows:
Quote:
Dim nomeIstanza As nomeDll.ClasseDll
Set nomeIstanza = New nomeDll.ClasseDll
nomeIstanza.MetodoDll ()
Re: Using VBA to a DLL created in VB6
I apologize if I answer only now but I was messed up until yesterday ...
I tried to do as you say, and the dll contains a form of class within a function with unique and simple:
Code:
Public Function Sum (ByRef x As Double, ByRef y As Double) As Double
Sum = x + y
End Function
Then on the excel file I added the dll (sees) that is in the same directory as the excel file. excel the form is as follows:
Code:
Option Explicit
Public Declare Function Sum Lib "mF_colors.dll" (ByRef x As Double, ByRef y As Double) As Double
Sub Test ()
Dim v (10) As Double
v (1) = 0.3
v (2) = 0.5
v (3) = Sum (v (1), v (2))
End Sub
But at this point gives me an error: "Could not find entry point in DLL Sum mF_colors.dll"
What does this mean?
Re: Using VBA to a DLL created in VB6
But that is not the method that I suggested myself.
The method is safe to import the Dll of the Rif, as explained above, and invoke methods and properties as follows:
Code:
Dim nomeIstanza As nomeDll.ClasseDll
Set nomeIstanza = New nomeDll.ClasseDll
nomeIstanza.MetodoDll ()
Then I am not clear why steps 2 Double ByRef numeric values.