Loading
If you have seen the Class Module creation in the page http://www.freeecommersetips.com/Software_tips_Visual_Basic_part3.asp
then it is easy to create a Active X Control (User Control).
The difference between the class module and Active X Control is that the Class module is only having a code where as Active X Control has code as well as graphical interface consisting of TextBoxes, Command Buttons, Forms etc. The coding part is stored in a file with extension .ctl where as the graphical interface is stored in a file with extension .ctx. When the project is compiled then a file with extension name .ocx is created, which is your active X Control (User Control), which can be saved in the visual project components directory and can be used in another project.
Active X User controls can create objects with properties, events and methods.
For creation of Properties
use Let and Get Subroutines.
For creation of methods use Private sub Function name routines. Methods always give results. Where as properties do not display result.
For creation of events user Private sub eventname.....End Sub
Consider a creation of an Active X Control (Active X control Name as Maths1.ocx) where on a form there are three text boxes for acceptance of two numbers, and one for display of result and 4 command buttons for calculating basic operations such as Addition, Subtraction, Multiplication and Division.
Four methods for the Active X control
Maths1.Add
Maths1.Subtract
Maths1.Multiply
Maths4.Divide
Two Properties of the Active X Control
Maths1.Value1
Maths1.Value2
Coding Part for the initialization of the variables inside the active x control
Private Sub UserControl_Initialize()
Dim Value1 As Long
Dim Value2 As Long
End Sub
Coding Part for the properties Value1 and Value2 inside the active x control
Private property Let Value1(By value New_Value1 as Long)
New_value1 = val(Text1.text)
Propertychanged "Value1"
End Property
Private Property Get Value1() as Long
Text1.text = Value1
End Property
Continued on the next page....