T'other day, I knocked together a macro, for a friend, to number the paragraphs in a Microsoft Word document ("manual" rather than hard-coded numbering, that is):
Sub NumberingParagraphs() Dim iParagraphs As Integer iParagraphs = ActiveDocument.Paragraphs.Count Selection.HomeKey unit:=wdStory Do While iCount < iParagraphs iCount = iCount + 1 Selection.TypeText iCount & ": " Selection.MoveDown unit:=wdParagraph Loop End Sub
My mate, being curious about, but not having experience of, the workings of such things, took a look and got the basic idea, but couldn't get his head around why the number of loops is seemingly instructed to be one less than the number of paragraphs. Surely, he said, it should be "less than or equal to," rather than "less than." Well, no. His kid got it straight away, and came up with a lovely semi-analogy; which I now share, in hopes that others who've been puzzled by this oft-seen seeming-paradox might see the light. Let's literally (yet figuratively) walk through the macro…