Each nongraphical control (all the controls except shape, line, image, and label) uses a window. Each window uses system resources, limiting the total number of windows that can exist at one time. The exact limit depends on the available system resources and the type of controls used.
To reduce consumption of system resources, use the shape, line, label, and image controls instead of picture box controls to create or display graphics.
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 254 control names per form. A control array counts only once toward this limit because all the controls in the array share a single control name.
The limit on control array indexes is 0 to 32,767 on all versions.
If you layer controls on top of each other, such as using several frame controls within other frames, Visual Basic will generally accept no more than 25 levels of nested controls.
The following table lists property limitations that apply to particular controls in Visual Basic.
Property | Applies to | Limitation |
List and ListCount | List box and combo box controls | Maximum number of items is 32K; the limit on the size of each item is 1K (1024 bytes). |
Text | Text box control | Limited to 64K. |
Caption | Label control | Limited to 1024 bytes. |
Command button, check box, frame, and option button controls | Limited to 255 characters. Any caption over these limits is truncated. Captions on custom control properties are limited to 32K. | |
Menu control | Limited to 235 characters. | |
Tag | All controls | Limited only by available memory. |
Name | All controls | Limited to 40 characters. |
Note In Visual Basic, control property names are limited to 30 characters.