Discovering Arrays, Page 2
First off, exactly what is an array? The Word thesaurus provides a few definitions; collection, selection and group. Oh, and dress.
Uhuh, spot the odd one out.
Those first three keywords probably best describe an array; it's a collection of information. A regular variable holds just one bit of information, such as a network username. An array however can hold many different bits of information, such as all your network usernames.
And that can be jolly useful. Let's say you need access the countries you ship to many times during your application. Wouldn't it be nice to throw all that information into one place and access it from wherever you wanted, without constantly dipping into a database?
That 'one place' can be an array.
Or perhaps you're creating a data entry application and want to take all the data from your user, temporarily storing it in a 'holding spot'. Then, at a set point, you may want to shove it all inside your database.
That 'holding spot' can be an array.
A friend of mine needed to take figures from a database and perform complex calculations on them within his Visual Basic application.
He threw the numbers into an array and started work.
I was once involved in a project where I needed to split a document up into separate paragraphs. Each paragraph needed analysing, words chopping and changing, lengths altering and so on.
Where did I store all that information? A dozen different variables one for each paragraph? Nope after all, what if there were more than a dozen paragraphs to analyse? Do I create a hundred different variables, just in case?
Nope, that wouldn't work it would use way too much memory and hey, what if I needed to analyse more than one hundred paragraphs?
Instead, I opted to store each paragraph individually within one single array. Simple.
So in brief, arrays are a groovy, tech-savvy way of storing many bits of information under one variable name.
This tutorial will show you how to use arrays; it presents the raw techniques and leaves you with thoughts on how you can make them work for you.
But be warned, this guide isn't full of ready-to-go, copy-and-paste code. Arrays just don't work like that. This tutorial merely gives ideas and techniques then leaves 'em with you to put to your full advantage.
Top Tip: This tutorial has also been created to complement future guides to three-tier architecture. So read on and swot up early!
And don't forget our usual VB-World guarantee; if you start using arrays and they don't dramatically improve your next application, we'll send you a hundred bucks*.
* Conditions apply. Offers ends yesterday.
Page 2 of 11