Metamorphing Machine I rather be this walking metamorphosis
than having that old formed opinion about everything!

WTF, VB6? Part 5

VB has a feature that, when I learned about it, I thought to myself: "WTF?"
I could only understand why it came to be because of my Programming like it's 1984 post.

See, For/Next is a well-known control flow statement used by several programming languages, not only VB.
But in VB, you can add the variable being used in the For right after the Next. It makes the code more readable:

For X = 0 To 26
For Y = 0 To 26
For Z = 0 To 26
(...)
Next Z
Next Y
Next X

Now, the odd part: VB allows an even more compact version of it:

For X = 0 To 26
For Y = 0 To 26
For Z = 0 To 26
(...)
Next Z, Y, X

When I first saw it I was like "Why the heck anyone would use it?"
Then, when researching for the 1984's post, I learned that at that time, no one used to indent their code.

For X = 0 To 26
For Y = 0 To 26
For Z = 0 To 26
(...)
Next Z, Y, X

Now, that made sense. Instead of three lines, you could close all those Fors with only one.

Andrej Biasic
2020-06-10