One of the class modules and modules in VB

Source: Internet
Author: User

The class module is an extended type. Besides attributes, there are also method events.
The module can have global (public) variables, global (API, constant, type) Declarations, Processes

Which has nothing to do with a specific form or controlCodePut it in another type of module-standard module (File Extension:. Bas. A process may be used to respond to events of several different objects. It should be placed in the standard module, rather than repeating the same code in the event process of each object.
Create objects using the class module (the file extension is. CLs) that can be appliedProgram. The standard module only contains code, and the class module contains both code and data, which can be considered as a control without physical representation.

The biggest benefit of a class module is encapsulation.

Class module can generate objects, such as dim A as mycls
A common module cannot generate objects. It can only be used as an extension of other modules, such as storing some global variables, global functions, and implementing some global functions.
If you use the same class function multiple times in the program and they are completely independent, you can consider using the class module.
If you want to do ActiveX dll or ActiveX EXE, remember to use the class module.

The class module is user-oriented in an object-oriented manner.

Setting a class is the most important thing in object-oriented design. Although VB does not support classes well, it can also be used, in the class module, you can set the methods and attributes of the class. For example, a class module called animal contains the public method eat, and the attributes include HP and MP, once you declare an animal object in other modules, you can use it. For example, if you declare a clslion class object, you can use clslion. eat (method), clslion. HP (attribute), similar to the self-contained objects in VB
The module stores global variables and functions for use by all modules.
--------------------------------------------------------------------------------
A module is a collection of things, and a class module is a collection of things that can be referenced as objects in the future.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.