An array is a collection of logically related data items, where each item can either be accessed in a sequential order, or through supplying its index position.Consider this:
Here we declare an index of dimension 5, which later on, comes to store six names, as, an index in an array starts at 0.
Then
for loops dumps
entire array onto
HTML page. People familiar with
for() {.} loop of JavaScript will notice that
for.next loop of VBScript is less cryptic.
Since now we have learnt how to create a VBScript array, let us try to sort this array. We'll sort
array in ascending order, that is, from
lowest to
top most in
alphabetical array.
So what's
logic?
1. Compare
first name with
second name 2. If
second name is lower than
first name, then swap 3. else 4. Compare
first name with
third name 5. If
third name is lower than
first name, then swap 6. else 7. Compare
first name with
fourth name 8. If
fourth name is lower than
first name, then swap 9. else 10. Compare
first name with
fifth name 11. If
fifth name is lower than
first name, then swap
So by
time we have reached
11th step, we have
lowest name at
first position.
The second round starts at
second index index, as
first we already know is
lowest.
1. Compare
second name with
third name 2. If
third name is lower than
second name, then swap 3. else 4. Compare
second name with
fourth name
and so on
I hope you've understood
logic now. Let's see how it looks programmatically:
For years I’ve been a stay-at-home mom, and I have only recently gone back into
work force. I’ve done pretty well for myself, but I could have really saved some time and frustration in
beginning if I’d just known a few things about how to use a computer.I come from
era of
typewriter and adding machine, and
computer was really intimidating to me at first. When I first entered
business world, I lived in constant fear of losing my document or crashing my machine. The word processor was my enemy, as was business email. The only thing I could figure out was how to open incoming messages. This was fine for trading those cute stories about angels with my friends, but it had my boss in a rage. Now, those of you who know
difference between an attachment and a hyperlink can stop reading, but if you’re as confused as I once was, read on. I’ve got some useful tips.
First, face your fear. The computer is just a machine. It’s not going to yell at you or blow up. Don’t be afraid to press a key or click on an icon (those little picture boxes that link you to programs and things.) Quite often I would end up staring at my screen afraid to move, because I didn’t know what to do next and I was afraid of
consequences of making
wrong decision. I wasted so much time. Just dive in. If you end up doing something that looks funny or wrong, you can almost always find a solution.
Second, save your work. This is so important in word processing programs. Have you ever been typing along, only to hit a wrong key and have your entire document disappear? Boy, I sure have. This doesn’t have to happen. If you just remember to hit "save" (under
file menu on most all word processors) every few sentences,
most you’ll ever lose is a phrase or two.