This article is the first page of the Chapter 11 lesson of the About Visual Basic "Complete Course" for VB.NET. Sign up for the entire course at ... this signup page
If you work through the About Visual Basic Complete Course up to this lesson, you can consider yourself "promoted" to Intermediate Programmer. There is nothing that illustrates the difference between the "Hello World" level of programming and higher levels of ability more than understanding how to work with Arrays and Collections. There is a huge world of tricks and techniques that we can use once we understand this key part of VB.NET.
The subtitle of this lesson, "the next best thing to a database" is actually only partly true. You can get a real feeling for what a database does by studying how arrays and collections are used, but they're really targeted at different requirements. A database is for storing huge amounts of information where the relationships between things are critical. If "automobile" is one type of data in the database and "person" is another, then "person owns automobile" is a relationship. That kind of thing would be difficult to do with arrays and collections.
While reading this chapter, you might want to remember the things that were covered in Chapter 7, Using Loops and Timers. The main reason for using arrays and collections is to use iterative processing with them, that is, process them with various types of program loops. (The text used in this course covers a new one, For Each, that is designed just for collections.)
Clever programming techniques involving arrays generally fall into the category of manipulating the array indexes. In this lesson, I'll show you an example that goes "Beyond the Book".
The programming techniques for collections, however, are mainly in defining (or discovering) collections with useful properties and methods. If you just want to keep track of a set of values, use an array. But if each value has attributes (properties) or actions (methods) associated with it, use a collection. The course text book covers an important collection, the collection of objects on a Form, but as you advance in your programming skill, you'll discover that .NET and systems written to work with .NET are all filled with collections to add performance and power to the systems you build.