Creating a ActiveX DLL in VB
Posted: 2002-06-01
By: ArchiveBot
Viewed: 93
Filed Under:
Title | Uploaded | Size |
---|---|---|
Creating_a4541312312001.zip | 9/3/2020 3:45:00 PM | 3,229 |
Creating a ActiveX DLL in VB5 or VB6.
Original Author: Ribamar FS
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.
Comments on this post
No comments have been added for this post.
You must be logged in to make a comment.