Fabulous Adventures In Coding
Eric Lippert is a principal developer on the C# compiler team. Learn more about Eric.
Before I get into today's entry, a brief editorial comment:
Pestilence is a frickin' pain in the rear. Famine was no problem at all, Rodney didn't touch me once, and Master Kaen fell to my powerful fists, but two Amulets of Life Saving, one Wand of Death and four potions of full healing were insufficient to keep Pestilence at bay. That's the second time Pestilence has ruined a perfectly good ascension. I need to figure out how to take that guy out.
(If you have no idea what I'm talking about, it's probably for the best.)
7) What does this silly program do?
On Error Resume NextFor i = 1 To 1/0 Print "x" & i & "x"nextPrint "Done"
It does (a).
This illustrates something interesting about the implementation of
That's not what happens. In fact, all three parameters -- the beginning, ending and step -- are calculated before the assignment to the loop variable. When the calculation of the limit fails the assignment never happens, so the loop variable keeps whatever value it had before. The loop variable was never initialized, so it's
There is no end to the shens you can pull with
I just tried this in XPSP3 and WSH 5.7. As written, you get no output. (Actually, it appears you get a blank line, but I'm not positive.) Removing the on error resume next causes a divide by zero error.