README.md
December 4, 2022 · View on GitHub
Description
Creating a ActiveX DLL in VB5 or VB6.
More Info
| Submitted On | 2001-12-30 12:49:56 |
| By | Ribamar FS |
| Level | Intermediate |
| User Rating | 4.8 (29 globes from 6 users) |
| Compatibility | VB 5.0, VB 6.0 |
| Category | Libraries |
| World | Visual Basic |
| Archive File | Creating_a4541312312001.zip |
Source Code
CRIATING ACTIVEXDLL WITH VB5 OR VB6
1 – Creating a new project ActiveX DLL
- Open a new project in VB
- Select a type ActiveX DLL
- Press Ctrl+S to save Class with name clsMath
- Change Instancing propertie to GlobalMultiUse.
- Select Project menu – Properties and change only:
- Change Project Name in General to DLLMath
- Change Project Description to My DLL Math
- In File menu - Save Project (DLLMath.vbp or other)
2 – WRITING CODE TO CLASS
Now writing functions of clsMath class.
Double click in class clsMath and paste the code below:
Public Function fSum(ByVal X As Long, ByVal Y As Long) As Long
fSum = X + Y
End Function
Public Function fSub(ByVal X As Long, Y As Long) As Long
fSub = X - Y
End Function
Public Function fMult(ByVal X As Long, Y As Long) As Long
fMult = X * Y
End Function
Public Function fDiv(ByVal X As Long, Y As Long) As Long
If Y <> 0 Then
fDiv = X / Y
Else
MsgBox " The divider must be different of zero.!"
End If
End Function
Press Ctrl+S to save.
3 – ADD A NEW CLASS
- In Project menu – Add Class Module
- Click in Class Module and in Open
- Rename this Class to clsTrig
- Change Instancing propertie of this Class to GlobalMultiUse.
- Double click in this Class to open
4 – WRITING CODE OF THIS NEW CLASS
Paste this code in clsTrig Class:
Public Function fSin(X As Double)
fSin = Sin(X)
End Function
Public Function fCos(X As Double)
fCos = Cos(X)
End Function
Press Ctrl+S to save this class with name clsTrig or other
5 – COMPILING THE DLL
In File menu - Make DLLMath and wait.
After VB compile then register automaticaly the DLL.
6 – TRY DLL
- Open a new project Standard EXE
- In Project menu – References - Browse
- Select DLLMath in your folder and OK.
Double click in form and paste in Load event.
Private Sub Form_Load()
Dim objMath As DLLMath.clsMath
' DLLMath here is name in Project - Properties - Project Name
Set objMath = New DLLMath.clsMath
MsgBox objMath.fSum(2, 6)
End Sub
Press F5 to run.
7 – HOW TO REFERENCE DLL AND CLASS
To make reference for all classes of a DLL
Dim NameVariableObject As NameOfDLL.NameOfClass
To make reference for a unique class of a DLL
Dim NameVariableObject As NameOfClass
Forgive my English. I studied the English little.