Create ActiveX dll with Visual Basic
Hello,
I am developing an Third party application where i need to create an ActiveX dll file using Visual basic, but i don't know how to start with the same and i find that this is possible but not difficult so please help me how to do it.
thanks for your help.
Re: Create ActiveX dll with Visual Basic
we need to assign the class in the Dll to an object variable. So add this code to the general declarations section of your forms code module:
'CSomeDll' is the name of the class in the DLL that has the method we want to use. We named it this in step 2 of creating the Dll.
Now add this code to Command1:
Code:
Private Sub Command1_Click()
Set X = New CSomeDll '<---Assigns an object reference
Text1.Text = X.ReverseString(Text1)
Set X = Nothing '<--------Release resources to the object
End Sub
Re: Create ActiveX dll with Visual Basic
Here I will provide you the details about how to create the ActiveX dll file.
creating the dll file.
- Start VB window it should be Visual studio 2005 and select ActiveX Dll for the project type.
- In the properties window for the Class (the only code window in the project), Provide any suitable name to your project such as 'createDll'. but the project name should be similar to form name.
- Browse Project from the menu, select Project1 Properties from the drop down list, change the project name to 'createDll', and provide the suitable Project Description to 'This is a useless DLL'. This description will Important from all aspects.
- You need to add a method (Function) to the class. You may take a any string as its parameter and may returns it spelled backwards. there will be no issues as this function will be already exists in VB, this will be just as for your example.
Code:
Option Explicit
Public Function ReverseString(ByRef SomeString As String) As String
ReverseString = StrReverse(SomeString)
End Function
- You are not ready to compile it by selecting File, in the drop-down list you will be allow to select Make SomeDll.dll and choose a safe place to save it.
- Save the project wherever you like and close it.
:thumbup1: and here your Dll is ready for a client application to use it.