| Topic: Project using ActiveX DLL What is DLL? A dynamic-link library(DLL) is a set of procedures that are external to your application, and can be called from your application. DLLs are not bound to your executable file, and so they can be linked to your application at run time, instead of being loaded at compile time. The libraries can be updated independently of the application and multiple applications can share a single DLL. Advantages of using DLLs: DLLs can accomplish tasks that are difficult with VB. Declaring a DLL Procedure: DLL procedures reside in files that are external to your VB application and so you must declare a procedure before you call it. Declaring a procedure provides VB with the information it needs to find and run the procedure you want to use. Steps used in creating an ActiveX DLL Project:
Figure 2
Figure 3 Public Sub setchart(ByVal data1, ByVal noofrows, ByVal noofcols) Figure 3a Save the project. Select ‘Make chartproj.dll’ from the file menu thereby saving the complete DLL procedure.file. This DLL file must be referenced by selecting the DLL project from the reference library window. Select references from the project window. You will get the list of reference libraries in the alphabetical order as shown in the figure 4. Select the file chartprj. In order to call the DLL procedure start the Standard Exe project. Drag a command button in the Design window. Change its caption and name as calldll and locate it as shown in the figure 5. Open the code window for the command button and enter the code for calling the DLL as shown in the figure 5a. Save the form and the project as dllform aand dllproj respectively. Run the project. You will have to enter the data for the number of rows, number of columns , values for the rows and columns. Finally you will get the bar chart for the supplied data as shown in the figure 6. Private Sub Command1_Click() Figure 5a
Figure 6
|