A couple more general tips, since you mentioned iteration is a little confusing (and it can be sometimes).
First, you'll notice that sometimes I put an "o" in front of a name like "oDrawDoc" and "oSheet", and other times I didn't. The times I didn't, like "Sheet" and "GeneralDimension", is because those are object classes that the software uses (that's why they're listed under the Objects node in the API reference manual).
oSheet and oGenDim, on the other hand, are instances of those object classes. I could have named them anything (except for one of the Inventor or VB classes/functions that are off-limits), but it's handy to name it something similar to the Class that it represents. So I just prefixed the object's class name with an "o", which is pretty standard practice (I'm guessing it stands for "object").
Whenever you want to work with an instance of some class of object (like a sheet, dimension, etc.), you first have to declare a new object as an instance of that class, and then initialize the object with some value.
So in the rule, this line:
Dim oDrawDoc as DrawingDocument
means "cast (or declare) oDrawDoc as a new object instance of the DrawingDocument class".
The next line:
oDrawDoc = ThisDoc.Document
means "initialize the oDrawDoc object by assigning ThisDoc.Document as its value". Now we can work with the current drawing document by using the oDrawDoc object.
Regarding the For loop specifically, you can see that, in contrast to how I explicitly declared oDrawDoc, for oSheet I simply said "For Each oSheet as Sheet..."
This is a nice, streamlined way to declare an object that you'll ONLY be using in the For loop. Once the last iteration of the "sheets" for loop is finished, or the loop is exited, the oSheet object will be wiped from memory, and you won't be able to use it anywhere after the for loop (you'll get an error if you try to). This is handy for some situations. However, if you DID need to use a sheet that your For loop found, you would need to declare the oSheet object OUTSIDE of the For loop, like this:
Dim oSheet As Sheet
For Each oSheet In oDrawDoc.Sheets
...
Hope all of that is helpful. I'm not a programming expert by any means (so some of what I said may be technically incorrect), but I've found that learning about classes, objects, methods, properties, etc. has been especially helpful to me in expanding my practical iLogic abilities. Hope you find the same 🙂