"Nothing is difficult in the world, as long as you are willing to climb." So you must have confidence to become a COM programmer, and you will definitely be able to.
In fact, every time we set the Text property of a text programming control, we are already using COM. Likewise, when the DAO data control runs the MoveNext method, and even when using VB control words, we are also using COM.
So, what is COM?
First of all, COM is a way of communication.
For example, like our TV remote control. When we press a certain channel button, the TV channel switches immediately; and when we press the switch button, the TV immediately turns off and so on. In fact, we don't care how they work, we just know that pressing the button can produce a certain action.
The principle of the program is the same. When changing the Text property of a text programming control, we don't know the principle. Maybe dozens of API functions will be called within the system? But for users, they only care about the text displayed in the text programming control.
Secondly, COM is a way to reuse code.
The biggest advantage of using COM is that once the COM communication method is established, it can be easily used multiple times anywhere. For example, when a user creates a COM component for displaying date and time, it can be used anywhere in any program. Not only VB applications and Excel programs can access it, but C applications can also access it.
Therefore, code reusability of COM components is the most important.
Again, COM is based on real objects.
Most components created with COM are based on actual objects, which means that once a component is created, its use is fairly easy. Just imagine, if we add another user to the computer system, which method of adding is as simple as Customer.Add? Is it to add a data processing code package, algorithm, or to add a larger database DLL to the application? Obviously, COM supports this simple operation.
So, COM is a method of communication, a method of code reuse, and based on real objects.
The remainder of this tutorial will briefly discuss COM and VB, including the creation of classes and how to convert a class into an actual object. Although the content here is too simple, it is the basis for future COM programming.
->