For...Next

I know what you’re thinking: "We just got finished looking at For...Next!" Well, sort of, but not really. An important difference between For Each...Next and For...Next is that with For Each...Next, you don’t have to know how many times you want to do something. With the For...Next construct, you must know exactly how many times you want to do something. Using For...Next is not necessarily a bad thing, however, because it gives you a lot of extra control. For example, the next script checks a number of performance indicators on the server (that is, process thread counts, page faults, working set sizes, and the like). The values for these items can change quite often, so you want to check them on a regular basis. However, frequent checking ...

Get Microsoft® Windows® Scripting Self-Paced Learning Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.