Class module and module 2 in VB

Source: Internet
Author: User

Q:
Visual Basic 6
Windows 98
What are the 'module' and 'class module' in VB? What are the benefits?

A:
The module is a. Bas file, which is mainly used to store codes separately for ease of management.
The class module is a. CLs file, which is mainly used to define the class and design ActiveX EXE and ActiveX DLL. Select "project | add class module" in VB to add a class module to the project. Then, you can use the "add process" command in the menu to add attributes, methods, and events.

What are the differences between global variables and public variables defined in the VB module.

There seems to be no difference in VB6.
I always like to use public

Global Variables
Suggestions
Avoid using global variables in components. In visual basic terminology, this indicates that there is no public or global variable in the standard. Bas module.
Why?
The global variable is not a real global variable. Each thread has its own copy. If several methods are executed in the same thread, they will see the same variables; otherwise they will access different copies of these variables. This means that you may assign a value to a global variable (in thread a), but another user (executed in thread B) cannot see the new value.
The reason is that visual basic uses "local thread storage (TLS)" to reference global variables. This means that each thread has its own copy of the Public variable, and because it has multiple copies, the global data is not really "Global ". That is to say, users that run in the same thread will access the same variable, whether or not they expect it.
Common traps
If the public variable is used in the standard. Bas module, the data may have been damaged when different threads provide services to different users who want to use the same data.
All I can find is this...

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.