The problem is that the casual user does not typically understand what an ActiveX control is, or what the consequences of allowing an ActiveX control to run might be. First of all, an ActiveX is a set of object-oriented programming (OOP) technologies and tools. Programmers writing for ActiveX create components, self-sufficient programs that can be run by the Windows operating system. The components, which are known as ActiveX controls, are roughly equivalent to Java applets.
One of the main advantages of ActiveX components is that they can be re-used by many applications.
Look at the following example of a component, a DLL file.
In India , and in most of its States, the retirement age for the government servant is 60 years. The person, after he or she completes his 60 years, retires on the last day of the month in which his or her date of birth falls.
It has one stipulation. If the date of birth falls on first of the month, he or she will retire on the last day of the preceding month.
This will be clear from the following example:
Date of Birth Date of Retirement
15-04-195030-04-2010
01-03-1950 28-02-2010
01-03-1948 29-02-2008
01-01-1952 31-12-2011
15-02-1950 28-02-2010
15-02-1948 29-02-2008
I have created one 'component' i.e. one DLL file to solve this problem of calculation which can be used in any MS Excel file or MS Access file through a very small piece of code in VBA, or can be embedded in any other Visual Basic or some other programming platform.
Take it from me at sanjaymohanb@yahoo.com
Open MS Excel. Save it as 'Book1'. Press Alt + F11. Following screen appears:
Date of Birth Date of Retirement
15-04-1950
Take it from me at sanjaymohanb@yahoo.com
Right click 'VBAPROJECT (Book1). Select Insert à Module. A module in the name of 'Module1' opens. Click Tools (on Menu bar) à References. Following window appears.
Click Browse. Find your DLL file. Select by pressing 'Open' command button. The file will be available in the window as shown above. Select it by clicking its check box. Press 'OK'. The VBA has accepted your DLL file and set a reference to it.
We shall write a little code, but before this, please remember (From VB 6 Help):
We shall write a little code, but before this, please remember (From VB 6 Help):
– After you set a reference to an object library (i.e. DLL file in this case) by selecting the check box next to its name, you can find a specific object and its methods and properties in the Object Browser.
– If you are not using any objects in a referenced library, you should clear the check box for that reference to minimize the number of object references Visual Basic must resolve, thus reducing the time it takes your project to compile. You can't remove a reference for an item that is used in your project.
– If you remove a reference to an object that your are currently using in your project, you will receive an error the next time you refer to that object.
– References not in use are listed alphabetically.
– You can't remove the "Visual Basic For Applications" and "Visual Basic objects and procedures" references, because they are necessary for running Visual Basic.
Write down following code in module. Please remember at various places the intelli-sense as build in VBA will work, and drop down menus will open automatically.
Write down following code in module. Please remember at various places the intelli-sense as build in VBA will work, and drop down menus will open automatically.
Close the Microsoft Visual Basic window. Go to MS Excel sheet; use this 'User Defined' function. The windows given below are self-explanatory.
No comments:
Post a Comment