A single project can contain up to 32,000 identifiers (non-reserved words), including (but not limited to) forms, controls, modules, variables, constants, procedures, functions and objects. Note that the actual number of identifiers is limited by available memory.
Variable names in Visual Basic cannot exceed 255 characters, and form, control, module, and class names cannot exceed 40 characters. Visual Basic does not limit the actual number of different objects in a project.
◆Control Limitations◆
Each nongraphical control (all controls except shapes, lines, images, and labels) uses a window. Each window uses system resources, so the total number of windows that can exist simultaneously is limited by available resources. The exact limit depends on available system resources and the type of control used. In order to reduce the consumption of system resources, you can use shape, line, label, and image controls instead of picture box controls when creating or displaying graphics.
1. Total number of controls
The maximum number of controls allowed on a single form depends on the type of controls used and available system resources. However, there is a fixed limit of only 254 control names allowed per form. Because all controls in the array share a control name, the control array only counts this limit once. In all versions, the limit on control array indexes is in the range 0 to 32,767. If you place controls on top of each control, such as nesting frame controls in a frame, Visual Basic generally only accepts no more than 25 levels of nested controls.
2. Restrictions on special controls
The following table lists the property restrictions for special controls in Visual Basic.
List and ListCount list box controls and combo box controls: the maximum number of items is 32K, and the size limit for each item is 1K (1024 bytes);
Text text box control: limited to 64K;
Caption label control: limited to 1024 bytes;
Command button controls, check box controls, frame controls, and option button controls: limited to 255 characters, and any titles that exceed these limits are truncated;
Title of custom control property: limited to 32K
Menu controls: limited to 235 characters
Tag all controls: limited to available memory size
Name all controls: limited to 40 characters
Note that in Visual Basic, control property names are limited to 30 characters.
◆Code restrictions◆
The total number of lines of code that can be loaded into a form, class, or standard module is limited to 65,534 lines. One line of code is limited to 1023 bytes. There can be no more than 256 leading spaces before the actual text in a line, and no more than 25 line continuation characters (_) in a logical line.
1. Procedures, types and variables
There is no limit on the number of procedures per module. Each process can contain up to 64K of code. If a procedure or module exceeds this limit, Visual Basic generates a compile-time error. If you encounter this kind of error, you can avoid this kind of error by splitting a particularly large procedure into several smaller procedures or moving the module-level declaration to another module. Visual Basic uses tables to store identifier names (variables, procedures, constants, etc.) in the code. Each table is limited to 64K.
2. Dynamic link library declaration table
Each form and code module uses a table that describes the structure of the dynamic link library entry point. Each structure is about 40 bytes, and the size of the table is limited to 64K, resulting in about 1500 declarations per module.
3. Project list
The entire application uses a table containing all the names. These names include:
·Constant name
·Variable name
·Customized type definition name
·Module name
·DLL procedure declaration name
There is no limit on the total size of the project name table, but case-sensitive entries must not exceed 32K. If the 32K limit is exceeded, the PRivate identifier can be reused in a different module to limit the number of case-sensitive entries to 32K.
4. Input table
Each time an identifier is referenced in a different module, an entry is created in the input table. Each such entry is at least 24 bytes, but limited to 64K, so each module can have approximately 2000 references.
5. Module entry table
Each module in this table is up to 125 bytes, but there is a total limit of 64K, so each project can produce approximately 400 modules.
◆Data Limitation◆
The following restrictions apply to variables in the Visual Basic language.
1. Form, standard and class module data
The VBA module data section (that is, the data defined in the declaration section) of any form or module in Visual Basic has up to 64K of data section, which includes the following data:
·Local variables declared with Static
·Module-level variables that are not arrays and variable-length strings
·Each module array and variable-length string occupies 4 bytes
2. Procedures, types and variables
If a procedure or module exceeds the 64K code limit, Visual Basic generates a compile-time error.
If the local variables defined in a procedure exceed 64K, a "Too many local non-static variables" error is generated.
If the module-level variables defined in a module exceed 64K, or the custom type defined is larger than 64K, an error "Fixed or static data cannot exceed 64K" occurs.
If you encounter this kind of error, you can avoid this error by splitting a too large procedure into several smaller procedures or moving the module-level declaration to another module.
Arrays declared as variables cannot use the entire array space; only array descriptors contribute to the 64K limit. For example, declared in a procedure or as a module-level declaration, Dimx(1000000)AsByte. However, if you declare a large, fixed-size array of records and then declare instances of those records as variables, a memory overflow can occur.
3. Customized types
Although the sum of many custom-type variable-length strings can exceed 64K (each custom-type variable-length string only occupies 4 bytes; and the actual content of the string is stored separately), the custom-type variables Cannot exceed 64K. Custom types can be defined with other custom types, but the total size of this type cannot exceed 64K.
4. Stack space
Parameters and local variables during runtime occupy stack space. Module-level variables and static variables do not occupy stack space because they are allocated in the data section of the form or module. Any DLL procedure that is called uses the stack when executing.
Visual Basic itself uses the stack, for example, to save intermediate values while evaluating expressions.
The total stack size available in Visual Basic is one megabyte (1MB) per thread. However, the stack size can exceed this limit if there is adjacent free memory.
◆System resource limitations◆
Certain limitations of Visual Basic and applications built with it are affected by Microsoft Windows. These restrictions vary depending on the version of Microsoft Windows.
Each open window uses system resources (the data area used by Microsoft Windows). If it is run beyond the system resource range, a runtime error "Insufficient available resources for Windows to run" will occur. You can select "About" from the "Help" menu of "Program Manager" or "File Manager" in Windows NT3.51, or select "About" from the "Windows Explorer Help" menu in Windows 95 and Windows NT4.0. to detect the percentage of remaining system resources. Applications can also call the Windows API GetFreeSystemResources to reclaim system resources, close windows (such as open forms and "code" windows, and windows in other applications) and exit running applications.
->