|
|
Title | Make an ActiveX DLL server |
Keywords | ActiveX, DLL, server, library |
Categories | ActiveX, Software Engineering |
|
|
Start a new project and select the project type ActiveX DLL. This creates a class module. Give the class a name. For example, MathServer might be a good name if the DLL will contain math functions.
Select the Project menu's Properties command. Change the project name to something meaningful like FunctionLibrary.
Give the class the public functions and routines you want the DLL to support. For example, you might give it a LogN function to calculate logarithms base N.
|
|
' Return the logarithm of operand in the given base.
Public Function LogN(ByVal operand As Single, ByVal base As _
Single) As Single
LogN = Log(operand) / Log(base)
End Function
|
|
From the File menu, select the Make Funclib.dll command.
Now you are ready to use the DLL in another program.
Start a new program. Select the EXE type.
Select the Project menu's References command. Find the DLL and select it. It will have the name you gave the project in step 2 (FunctionLibrary in this example).
In the code, create a new MathServer object and invoke its methods.
|
|
Private Sub Command1_Click()
Dim math_server As MathServer
Dim operand As Single
Dim base As Single
operand = CSng(txtOperand.Text)
base = CSng(txtBase.Text)
Set math_server = New MathServer
txtResult.Text = Format$(math_server.LogN(operand, _
base))
End Sub
|
|
|
|
|
|