I'm working on an small RTS project and I've created a drag box to select units with but I'm not sure what the math is to work out if a unit should be selected or not, because it's not just a simple test to see if a point is in a box because units are also boxes not points.
Decide now what the rule will be. Pick something sensible like "for the purposes of selection by box, the centre of a unit's box shall be the point considered" or "for the purposes of selection by box, if ANY point in a unit's box is covered by the selection box, the unit is selected" or any other consistent, coherent scheme.
Using a couple of for loops to test for lots of points just seems like an inefficient way of doing things. Are you sure there isn't another test that can be done that works for every point in a rectangle?
You can save yourself some time by only checking the corners of the unit box; so long as the selection box is bigger than any one unit box, and all boxes are rectangular, it's enough to test just the corners. However, if you have some situation like a very narrow but wide selection box, this could go right through the middle of a unit without clipping any corners.
Alternatively, there are some neat things you can do involving triangles and matrices and what have you. Detecting if things are inside other things is a very big field with lots of clever solutions.