Learn More Study Less
Learn More Study Less
Learn More Study Less
Introduction
"I amar prestar aen-the world has changed." You may recognize this as the first words
from the movie The Lord of the Rings: The Fellowship of the Ring. These words are just
as true in the world of Visual Basic development as they were in Middle Earth. Our
world has changed. This is the first in a series of articles that describe the fundamental
changes in Microsoft Visual Basic® and how to do today with Visual Basic .NET what
you used to do with earlier versions of Visual Basic.
The original versions of Visual Basic provided control arrays for managing the controls
on your forms. Control arrays had several benefits. They allowed you to share event
procedures for a set of controls. For example, one GotFocus event procedure could
handle the focus event for all of the text boxes on your forms. Control arrays provided a
mechanism for iterating through a set of controls and for adding controls at runtime. And
if you were concerned about system resources, using a control array counted as one
control, regardless of the number of controls in the control array.
There were limits to control arrays as well. You could only put controls of the same type
in a control array. If one of your input boxes was a masked edit control, it could not be in
the same control array as your text boxes.
Control arrays were not consistent in the language. They were not quite collections and
not quite arrays. This is why they are not provided in Visual Basic .NET. Instead, Visual
Basic .NET has a rich set of features that provide all of the benefits of control arrays
without the limitations.
Note Actually, Visual Basic .NET does support control arrays through the
Microsoft Visual Basic .NET Compatibility library. This library allows you to
retain some of the Visual Basic 6.0 features in Visual Basic .NET to simplify the
migration process. Features of this library should be used only for migration.
Conclusion
The world of Visual Basic development has changed, but it has only gotten better. The
hard part is learning all of the differences and how best to take advantage of the many
new features.
Control arrays are gone, but with the new event handlers and controls collection, we can
achieve the same functionality with less code, easier maintenance, and no limitations.